简体   繁体   English

使用 jsPDF 将隐藏的 div 导出为 PDF

[英]Export the hidden div as PDF using jsPDF

I am trying to create a PDF from html div content.我正在尝试从 html div 内容创建 PDF 。 The PDF generation is working fine expect from hidden div items. PDF 一代工作正常,除了隐藏的 div 项目。

Here is my hidden div这是我隐藏的 div

<div id="listview" style="display: none;">test</div>

And my PDF render scripts还有我的 PDF 渲染脚本

var pdf = new jsPDF('p', 'pt', 'letter');
        var options = {
            background: '#fff'  
        };
        pdf.addHTML($('#listview')[0], options, function () {
                pdf.save('searchresult.pdf');
        });

The content on #listview will be appended dynamically. #listview 上的内容将动态附加。 The PDF render throws below error PDF 渲染抛出以下错误

html2pdf.js:115 Uncaught Missing source element or string.

Thanks in advannce for the support预先感谢您的支持

The item is resolved with toggle on the id.该项目通过 id 上的切换来解决。 This post can be closed这个帖子可以关了

$("#listview").toggle(); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM