最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How can I add div content to a new page in jspdf? - Stack Overflow

programmeradmin4浏览0评论

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

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

Share Improve this question edited Feb 7, 2016 at 14:11 dontknow asked Feb 7, 2016 at 14:06 dontknowdontknow 891 gold badge1 silver badge10 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4

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

发布评论

评论列表(0)

  1. 暂无评论