如何在jspdf中将div内容添加到新页面? [英] How can I add div content to a new page in jspdf?

查看:659
本文介绍了如何在jspdf中将div内容添加到新页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在jspdf中将div内容添加到新页面?我尝试使用< br> 并创建了一个新页面但我看不到内容。

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');
            });  

谢谢! :)

推荐答案

使用:

doc.addPage();

这将为您添加一个新页面,之后您可以添加您的内容。

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

或者如果您想根据内容的高度添加新页面,请查看以下链接: jsPDF多页PDF使用HTML渲染器

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

这篇关于如何在jspdf中将div内容添加到新页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆