Javascript React html2canvas jspdf多页
我希望使用html2canvas和jspdf下载多页PDF 我可以完成单页操作,但没有以下问题:Javascript React html2canvas jspdf多页,javascript,reactjs,jspdf,html2canvas,react-pdf,Javascript,Reactjs,Jspdf,Html2canvas,React Pdf,我希望使用html2canvas和jspdf下载多页PDF 我可以完成单页操作,但没有以下问题: printDocument = () => { const input = document.getElementById('divToPrint'); html2canvas(input, {scale: 4,}) .then((canvas) => { const imgData = canvas.toDataURL('image/png'); const p
printDocument = () => {
const input = document.getElementById('divToPrint');
html2canvas(input, {scale: 4,})
.then((canvas) => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF('l', 'pt', 'a4', true);
var width = (pdf.internal.pageSize.getWidth() * 0.90);
var height = (pdf.internal.pageSize.getHeight() * 0.90);
pdf.addImage(imgData, 'PNG', 0, 0, width, height, '','FAST');
// pdf.output('dataurlnewwindow');
pdf.save("download.pdf");
});
pdf.addPage();
我还知道我可以添加包含以下内容的页面:
printDocument = () => {
const input = document.getElementById('divToPrint');
html2canvas(input, {scale: 4,})
.then((canvas) => {
const imgData = canvas.toDataURL('image/png');
const pdf = new jsPDF('l', 'pt', 'a4', true);
var width = (pdf.internal.pageSize.getWidth() * 0.90);
var height = (pdf.internal.pageSize.getHeight() * 0.90);
pdf.addImage(imgData, 'PNG', 0, 0, width, height, '','FAST');
// pdf.output('dataurlnewwindow');
pdf.save("download.pdf");
});
pdf.addPage();
如果我把一个三页的文档分成三个部分,,而且代码>如何创建和下载所有3个页面
非常感谢您的帮助