0

I have submitted a form resulting in a webpage, I need to download that webpage in any format.

How can I do that?

piet.t
  • 11,718
  • 21
  • 43
  • 52
Navya
  • 49
  • 5

1 Answers1

0

Ya its very easy to do with javascript. Hope this code is useful to you.

Yes, Use jspdf To create a pdf file.

<div id="content">
     <h3>Hello, this is a H3 tag</h3>

    <p>a pararaph</p>
</div>
<div id="editor"></div>
<button id="cmd">Generate PDF</button>

<script>
    var doc = new jsPDF();
    var specialElementHandlers = {
        '#editor': function (element, renderer) {
            return true;
        }
    };

    $('#cmd').click(function () {
        doc.fromHTML($('#content').html(), 15, 15, {
            'width': 170,
                'elementHandlers': specialElementHandlers
        });
        doc.save('sample-file.pdf');
    });

    // This code is collected but useful, click below to jsfiddle link.
</script>
Badri Gs
  • 320
  • 2
  • 11