如何解决使用jspdf在单独的页面上将两个div保存为pdf
我有这段代码可将ID为invoice
的div导出为pdf(按下按钮时)。
exportAsPDF(div_id)
{
var doc = new jspdf();
var content = document.getElementById('invoice')
html2canvas(content)
.then(canvas => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jspdf({
orientation: 'portrait',});
const imgProps= pdf.getImageProperties(imgData);
const pdfWidth = pdf.internal.pageSize.getWidth();
const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width;
pdf.addImage(imgData,'pdf',pdfWidth,pdfHeight);
pdf.save('download.pdf');
});
}
但是,我希望invoice
显示在第一页上,details
显示在第二页(同一文档)上。
我该如何实现?我看过很多文档,但似乎看不到正确的解释。
例如我的HTML是:
<div id='invoice'>
<span> Some text </span>
</div>
<div id='details'>
<span> Some other text </span>
</div>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。