简体   繁体   中英

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. 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?
  • Check the Javascript console for errors
  • Check examples like this or questions like this to find any errors

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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