试试jsPDF
.html()
而不是
.fromHtml()
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.debug.js"
integrity="sha384-NaWTHo/8YCBYJ59830LTz/P4aQZK1sS0SneOgAvhsIl3zBu8r9RevNg5lHCHAuQ/"
crossorigin="anonymous"></script>
<script src="~/lib/html2canvas/html2canvas.min.js"></script></script>
<!-- html2canvas 1.0.0-alpha.11 up to v1.0.0-rc.1 works, current version may not work -->
<script>
function download() {
let pdf = new jsPDF('p', 'pt', 'letter');
pdf.html(document.getElementById('toPdf'), {
callback: function () {
pdf.save('myDocument.pdf');
window.open(pdf.output('bloburl')); // To debug.
}
});
}
</script>