【发布时间】:2019-06-05 05:18:39
【问题描述】:
我想使用jsPDF.html 将html页面转换为pdf,我正在使用这个代码:
savePdf () {
var pdf = new jsPDF({unit: 'mm', format: 'a4', orientation: 'portrait' })
pdf.html(document.getElementById('printable-cv'), {
callback: function (pdf) {
pdf.save('cv-a4.pdf');
}
})
}
但我收到错误html2canvas not loaded:是我忘记了吗?我确实有 html2canvas
"html2canvas": "^1.0.0-alpha.12"
我正在使用带有 webpack 的 vuejs。
在同一页面中,我目前正在使用 html2pdf 和以下代码:
savePdf0 () {
let opt = {
filename: 'cv.pdf',
enableLinks: true,
image: { type: 'jpeg', quality: 0.98 },
html2canvas: {
scale: 8,
useCORS: true,
width: 310,
letterRendering: true,
},
jsPDF: { unit: 'mm', format: 'a4', orientation: 'portrait' },
}
html2pdf().set(opt).from(document.getElementById('printable-cv')).save()
}
正确找到 html2canvas。
html2canvas not loaded 的真正含义是什么?我该怎么做才能加载它?
【问题讨论】:
-
我添加了一个显示问题的代码框:codesandbox.io/s/6vmqpwy0xr
标签: jspdf html2canvas