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

江枫思渺然 提交于 2019-12-23 20:06:29

问题


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! :)


回答1:


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



来源:https://stackoverflow.com/questions/35254465/how-can-i-add-div-content-to-a-new-page-in-jspdf

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!