I am hoping to use html2canvas and jspdf to download a multi page PDF.
I can do single pages no problem with the following:
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");
});
I also know I can add a page with the following:
pdf.addPage();
If I had a three page document split into 3 divs <div id="divToPrint1"> ... </div>, <div id="divToPrint2"> ... </div>, and <div id="divToPrint3"> ... </div> how would I create and download all 3 pages together.
Any help is greatly appreciated!