dontknow
dontknow

Reputation: 89

How can I add div content to a new page in jspdf?

How can I add div content to a new page in jspdf? I tried to use <br> and it creates a new page but I can't see the contents.

 <div id="printArea">
    <div style="margin: 3px 430px;">First Page</div>
    <div>Place content to Second Page</div>
  </div>

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

            $('#wrapper_div').on("click", "#print", function () {
                doc.fromHTML($('#printArea').html(), 15, 15, {
                    'width': 170,'elementHandlers': specialElementHandlers
                });
                doc.output('datauri');
            });  

Thank you! :)

Upvotes: 3

Views: 11088

Answers (1)

Arpit Goyal
Arpit Goyal

Reputation: 1005

Use:

doc.addPage();

This will add a new page for you and after that you can add your content.

or if you want to add new page depending on content's height check this link : jsPDF multi page PDF with HTML renderer

Upvotes: 4

Related Questions