jsPDF + rasterizeHTML not working?

♀尐吖头ヾ 提交于 2019-12-07 02:21:43

问题


jsPDF's addHTML requires html2canvas.js or rasterizeHTML.js.

I want to use rasterizeHTML.js but it doesn't work. Couldn't find any example online.

Working with html2canvas.js:

html

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>


<body>
    <p id="to-pdf">HTML content...</p>
</body>

js

var pdf = new jsPDF('p','pt','a4');
pdf.addHTML(document.body,function() {
    pdf.save('web.pdf');
});

Not working with rasterizeHTML.js (nothing happens; no errors):

html

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/rasterizehtml/1.2.2/rasterizeHTML.allinone.js"></script>


<body>
    <p id="to-pdf">HTML content...</p>
</body>

js

var pdf = new jsPDF('p','pt','a4');
pdf.addHTML(document.body,function() {
    pdf.save('web.pdf');
});

What am I missing?

来源:https://stackoverflow.com/questions/38907272/jspdf-rasterizehtml-not-working

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!