简体   繁体   English

Html to pdf Jspdf

[英]Html to pdf Jspdf

When I'm converting my html div to pdf using Jspdf library the generated pdf is not showing the whole content of mydiv.It only shows little html but not complete div. 当我使用Jspdf库将我的html div转换为pdf时,生成的pdf没有显示mydiv的全部内容。它只显示小html而不是完整的div。 What I am missing in this ? 我在这里缺少什么?

<button id="b2">Export to pdf</button>
<script>

var doc = new jsPDF();
var specialElementHandlers = {
    '#editor': function (element, renderer) {
        return true;
    }
};
$('#b2').click(function () {
    doc.fromHTML($('#mydiv').html(), 15, 15, {
        'width': 170,
        'elementHandlers': specialElementHandlers
    });
    doc.save('sample-file.pdf');
});


</script>

Things you can do: 你可以做的事情:

  • Check if your IDs are correct: #editor for the specialElementHandlers and #mydiv in the click function? 检查您的ID是否正确: #editor for specialElementHandlers和#mydiv在click函数中?
  • Check the Javascript console for errors 检查Javascript控制台是否有错误
  • Check examples like this or questions like this to find any errors 检查这样的示例类似的问题以查找任何错误

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

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