我已经为angular安装了jspdf。我有一些html内容要显示在模态,我需要下载在pdf。每当我下载时,我得到的是空的pdf文件下载。
downloadPdf(): void {
const data = document.getElementById('pdfData');
html2canvas(data).then(canvas => {
const imgWidth = 150;
const pageHeight = 200;
const imgHeight = canvas.height * imgWidth / canvas.width;
const heightLeft = imgHeight;
const contentDataURL = canvas.toDataURL('image/png');
const pdf = new jsPDF('p', 'pt', 'a4');
const position = 0;
pdf.addImage(contentDataURL, 'PNG', 0, position, imgWidth, imgHeight);
pdf.save('invoice.pdf');
});发布于 2020-10-11 22:23:49
使用jspdf.html()方法代替http://raw.githack.com/MrRio/jsPDF/master/docs/module-html.html。
https://stackoverflow.com/questions/64203236
复制相似问题