jspdf convert html to pdf with multiple pages

matts1189 picture matts1189 · Feb 16, 2017 · Viewed 13.4k times · Source

I'm using jsPdf and html2pdf to convert html to a pdf file.

I can convert the html fine and download the file but if the html is too big to fit onto a single page, it does not create the other page(s), how do I do this?

code is:

 var pdf = new jsPDF('l', 'pt', 'a4');
 pdf.canvas.height = 72 * 11;
 pdf.canvas.width = 72 * 8.5;
 html2pdf(document.getElementById(id), pdf, function(pdf){
     pdf.save('file.pdf');
 });

Answer

Bilal Sardar picture Bilal Sardar · Feb 17, 2017

Another Solution.

var pdf = new jsPDF('p', 'pt', 'a4');
var options = {
     pagesplit: true
};

pdf.addHTML($(".pdf-wrapper"), options, function()
{
pdf.save("test.pdf");
});

Source : jsPDF multi page PDF with HTML renderrer

another answer : jsPDF multi page PDF with HTML renderrer