pdf.addHtml does not work if there are svg images on the web page. I am copying the solution here based on a picture already on the canvas.
Here are the numbers (paper width and height) that I found to work. This still creates a small portion of the overlap between pages, but is good enough for me. if you can find the official number from jsPDF, use them.
var imgData = canvas.toDataURL('image/png'); var imgWidth = 210; var pageHeight = 295; var imgHeight = canvas.height * imgWidth / canvas.width; var heightLeft = imgHeight; var doc = new jsPDF('p', 'mm'); var position = 0; doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; while (heightLeft >= 0) { position = heightLeft - imgHeight; doc.addPage(); doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } doc.save( 'file.pdf');'
source share