admin管理员组文章数量:1389925
I'm trying to use jsPDF and html2canvas with es6.
I'm Importing html2canvas and jsPDF but getting an error on the addHTML when I ment out the addHTML the pdf is generated.
any clue what is the problem?
Thanks.
jspdf.debug.js:3754Uncaught Error: You need either or .js(…)jsPDFAPI.addHTML @ jspdf.debug.js:3754(anonymous function) @ index.js:12(anonymous function) @ bundle.js?V1.27.2:31546(anonymous function) @ bundle.js?V1.27.2:31547__webpack_require__ @ bootstrap f7845b2…:555fn @ bootstrap f7845b2…:86(anonymous function) @ bootstrap f7845b2…:578__webpack_require__ @ bootstrap f7845b2…:555(anonymous function) @ bootstrap f7845b2…:578(anonymous function) @ bootstrap f7845b2…:578
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
doc.setFontSize(40);
doc.text(35, 25, "Paranyan loves jsPDF");
doc.addHTML(document.footer,function() {
pdf.save('web.pdf');
});
<footer>
<p id="to-pdf">HTML content...</p>
</footer>
I'm trying to use jsPDF and html2canvas with es6.
I'm Importing html2canvas and jsPDF but getting an error on the addHTML when I ment out the addHTML the pdf is generated.
any clue what is the problem?
Thanks.
jspdf.debug.js:3754Uncaught Error: You need either https://github./niklasvh/html2canvas or https://github./cburgmer/rasterizeHTML.js(…)jsPDFAPI.addHTML @ jspdf.debug.js:3754(anonymous function) @ index.js:12(anonymous function) @ bundle.js?V1.27.2:31546(anonymous function) @ bundle.js?V1.27.2:31547__webpack_require__ @ bootstrap f7845b2…:555fn @ bootstrap f7845b2…:86(anonymous function) @ bootstrap f7845b2…:578__webpack_require__ @ bootstrap f7845b2…:555(anonymous function) @ bootstrap f7845b2…:578(anonymous function) @ bootstrap f7845b2…:578
import html2canvas from 'html2canvas';
import jsPDF from 'jspdf';
doc.setFontSize(40);
doc.text(35, 25, "Paranyan loves jsPDF");
doc.addHTML(document.footer,function() {
pdf.save('web.pdf');
});
<footer>
<p id="to-pdf">HTML content...</p>
</footer>
Share
Improve this question
asked Nov 20, 2016 at 19:30
user2428524user2428524
1081 gold badge2 silver badges9 bronze badges
1
- Would like to know if you ever solved this problem. – TheNastyOne Commented Sep 14, 2017 at 22:44
3 Answers
Reset to default 2Include the following script in index.html instead of the import in typescript file
<script src="https://cdnjs.cloudflare./ajax/libs/html2canvas/0.4.1/html2canvas.js"></script>
From https://github./MrRio/jsPDF/issues/1225:
jsPDF requires html2canvas to be on the window:
window.html2canvas = html2canvas
Alternatively to calling window.
you can also modify your import to this: import * as jsPDF from 'jspdf'
本文标签: javascriptUsing jsPDF and html2canvas with es6Stack Overflow
版权声明:本文标题:javascript - Using jsPDF and html2canvas with es6 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744591056a2614492.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论