I have the same working issue. Searching in MrRio github I found this: https://github.com/MrRio/jsPDF/issues/101

Basically, you have to check the actual page size always before adding new content

doc = new jsPdf();
...
pageHeight= doc.internal.pageSize.height;

// Before adding new content
y = 500 // Height position of new content
if (y >= pageHeight)
{
  doc.addPage();
  y = 0 // Restart height position
}
doc.text(x, y, "value");
Answer from MARC.RS on Stack Overflow
Top answer
1 of 11
69

I have the same working issue. Searching in MrRio github I found this: https://github.com/MrRio/jsPDF/issues/101

Basically, you have to check the actual page size always before adding new content

doc = new jsPdf();
...
pageHeight= doc.internal.pageSize.height;

// Before adding new content
y = 500 // Height position of new content
if (y >= pageHeight)
{
  doc.addPage();
  y = 0 // Restart height position
}
doc.text(x, y, "value");
2 of 11
58

here's an example using html2canvas & jspdf, although how you generate the canvas doesn't matter--we're just going to use the height of that as the breakpoint on a for loop, in which a new page is created and content added to it.

after the for loop, the pdf is saved.

function makePDF() {

   var quotes = document.getElementById('container-fluid');
   html2canvas(quotes).then((canvas) => {
        //! MAKE YOUR PDF
        var pdf = new jsPDF('p', 'pt', 'letter');

        for (var i = 0; i <= quotes.clientHeight/980; i++) {
            //! This is all just html2canvas stuff
            var srcImg  = canvas;
            var sX      = 0;
            var sY      = 980*i; // start 980 pixels down for every new page
            var sWidth  = 900;
            var sHeight = 980;
            var dX      = 0;
            var dY      = 0;
            var dWidth  = 900;
            var dHeight = 980;

            window.onePageCanvas = document.createElement("canvas");
            onePageCanvas.setAttribute('width', 900);
            onePageCanvas.setAttribute('height', 980);
            var ctx = onePageCanvas.getContext('2d');
            // details on this usage of this function: 
            // https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Using_images#Slicing
            ctx.drawImage(srcImg,sX,sY,sWidth,sHeight,dX,dY,dWidth,dHeight);

            // document.body.appendChild(canvas);
            var canvasDataURL = onePageCanvas.toDataURL("image/png", 1.0);

            var width         = onePageCanvas.width;
            var height        = onePageCanvas.clientHeight;

            //! If we're on anything other than the first page,
            // add another page
            if (i > 0) {
                pdf.addPage(612, 791); //8.5" x 11" in pts (in*72)
            }
            //! now we declare that we're working on that page
            pdf.setPage(i+1);
            //! now we add content to that page!
            pdf.addImage(canvasDataURL, 'PNG', 20, 40, (width*.62), (height*.62));

        }
        //! after the for loop is finished running, we save the pdf.
        pdf.save('Test.pdf');
  });
}
🌐
Phppot
phppot.com › php › converting-html-into-multi-page-pdf-using-javascript-library
Converting HTML into Multi-page PDF using JavaScript library - Phppot
December 3, 2022 - Converting HTML to multi-page PDF by using UI template source and jsPDF JavaScript library functions.
Discussions

Can I use html() multiple times in a PDF
I want to export a PDF in a function. At the same time, the content inside is generated by using .html() many times. If only once .html() there is no problem at all. But I found that I used it twic... More on github.com
🌐 github.com
25
December 3, 2020
JSPDF - Page Split breaks the content after it's page size exceeds
There was an error while loading. Please reload this page. ... I am using jsPDF in my application to generate PDFs. More on github.com
🌐 github.com
27
July 5, 2015
jspdf convert html to pdf with multiple pages
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 pag... More on stackoverflow.com
🌐 stackoverflow.com
html - Multiple pages pdf using jspdf - Stack Overflow
I'm a Javascript beginner and for a desktop application (using electron) I'm trying to gather the content of several divs (only images jpeg) to create a pdf when the user clicks on the "download" b... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
github.com › parallax › jsPDF › issues › 2759
recursively add multiple pages using jspdf.html · Issue #2759 · parallax/jsPDF
June 8, 2020 - Hi, I am using jsPDF to generate pdf from html. Content of each div need to be added as new page in PDF, I tried the following code to recursively add the content from the div Counter-0.....
Published   Jun 08, 2020
🌐
Codementor
codementor.io › community › convert html/css content to a sleek multiple page pdf file using jspdf javascript library
Convert HTML/CSS Content to a Sleek Multiple Page PDF File Using jsPDF JavaScript library | Codementor
June 20, 2018 - At the end of this lesson, you will be able to do the following: • Use the fromHtml API End Point to get our HTML content container wrapper. • Create a PDF with multiple pages. • Create a function to convert images to base64 image Uniform Resource Locator (URL) and use in our header. • Add header and footer text (like page count) to every single generated jsPDF page.
🌐
Freakyjolly
freakyjolly.com › multipage-canvas-pdf-using-jspdf
Generate Multipage PDF using Single Canvas of HTML Document using jsPDF
April 30, 2022 - <script src="https://code.jquery.com/jquery-1.12.4.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script> <script src="https://html2canvas.hertzen.com/dist/html2canvas.js"></script> Step 2) We will add JS code for HTML to PDF conversion · In this code block we have used html2canvas function which will give canvas of HTML section we specified, then after getting canvas object we will add PDF page using a jsPDF method and add break-up of canvas s image(JPG) in PDF page.
🌐
YouTube
youtube.com › watch
How to add multiple pages in jspdf | jspdf tutorial | html to pdf - YouTube
Enjoy the videos and music you love, upload original content, and share it all with friends, family, and the world on YouTube.
Published   December 14, 2018
🌐
Pdfnoodle
pdfnoodle.com › blog › generating-pdfs-from-html-with-jspdf
Generating PDFs from HTML with jsPDF and javascript
January 30, 2025 - In this guide, we’ll explore how to convert HTML to PDF using jsPDF, share best practices for styling and performance, and compare jsPDF to more advanced tools like Playwright, Puppeteer, or dedicated PDF APIs.
Find elsewhere
🌐
PixelsTech
pixelstech.net › home › articles › create multiple page pdf with top and bottom margins using jspdf addimage
Create Multiple Page PDF with Top and Bottom Margins using jsPDF addImage | PixelsTech
March 6, 2025 - const imgHeight = fullHeight * scale; // height of the HTML content image const pageHeight = 297; // A4 height in mm let heightLeft = imgHeight; let position = 0; let currentPage = 1; // if we have more than one page, we need to add padding to the top and bottom if(imgHeight > pageHeight){ // Additional pages while (heightLeft > 0) { doc.addImage( jpegDataUrl, 'JPEG', 0, // x position position, // y position pdfWidth, // width imgHeight, // height: ensure last page fits correctly "", "FAST" ); currentPage++; position -= pageHeight; // Move the starting position down heightLeft -= pageHeight; if(heightLeft > 0){ doc.addPage(); } } } else { // Single page ...
🌐
GitHub
github.com › parallax › jsPDF › issues › 3074
Can I use html() multiple times in a PDF · Issue #3074 · parallax/jsPDF
December 3, 2020 - I want to export a PDF in a function. At the same time, the content inside is generated by using .html() many times. If only once .html() there is no problem at all. But I found that I used it twic...
Published   Jan 25, 2021
🌐
GitHub
github.com › parallax › jsPDF › issues › 650
JSPDF - Page Split breaks the content after it's page size exceeds · Issue #650 · parallax/jsPDF
July 5, 2015 - ... function demoFromHTML() { var pdf = new jsPDF('p','pt','a4'); pdf.addHTML(document.body,{pagesplit:true},function() { pdf.save('Test.pdf'); }); document.getElementById('buttons').style.visibility = 'hidden'; } And my webpage contains some ...
Published   Dec 16, 2015
🌐
Nutrient
nutrient.io › blog › sdk › how to convert html to pdf using react
Generate PDFs from HTML in React with jsPDF
May 14, 2025 - This guide shows how to import jsPDF(opens in a new tab), reference your JSX with useRef, and export a polished PDF — plus tricks for custom page size, multiple pages, and custom fonts. jsPDF works for basic needs but lacks external CSS support and requires a font converter for non‑standard fonts. If you look at the live demo examples(opens in a new tab) of jsPDF, you’ll see it’s possible to convert images, font faces, font sizes, circles, rectangles, triangles, tables, lines, languages, and more into PDF format. You can also convert HTML into multiple pages with page breaks and add password protection and annotations.
🌐
Phppot
phppot.com › javascript › jspdf-html-example
jsPDF HTML Example with html2canvas for Multiple Pages PDF - Phppot
February 24, 2024 - The jsPDF core alone has many features to create PDF documents on the client side. But, for converting HTML to a multi-page PDF document, the core jsPDF library is enough.
Top answer
1 of 2
2

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

2 of 2
0

If above answer does not work i have done it like this :

download and include in order :

  1. Jquery
  2. html2canvas
  3. jspdf

google them they are easy to find. then have your printable code in a div wrapper report. and call the function with print button. for example (In jsfiddle code will not work because it does not allow external code from non cdn sites but it will work on server)

$(document).ready(function() {
   var form = $('#report');
   var cache_width = form.width();
   var a4 = [595.28, 841.89];


   $('#create_pdf').on('click', function() {
     $('body').scrollTop(0);
     createPDF();
   });

   //create pdf
   function createPDF() {
     getCanvas().then(function(canvas) {
       var imgWidth = 200;
       var pageHeight = 290;
       var imgHeight = canvas.height * imgWidth / canvas.width;
       var heightLeft = imgHeight;
       var doc = new jsPDF('p', 'mm');
       var position = 0;

       var img = canvas.toDataURL("image/jpeg");




 doc.addImage(img, 'JPEG', 0, position, imgWidth, imgHeight);
   heightLeft -= pageHeight;



   while (heightLeft >= 0) {
     position = heightLeft - imgHeight;
     doc.addPage();
     doc.addImage(img, 'JPEG', 0, position, imgWidth, imgHeight);
     heightLeft -= pageHeight;
   }


   doc.save('Report.pdf');
   form.width(cache_width);
  });
 }


 // create canvas object
   function getCanvas() {
     form.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
     return html2canvas(form, {
       imageTimeout: 2000,
       removeContainer: false
     });
   }

});

https://jsfiddle.net/vnfts73o/1

🌐
Stack Overflow
stackoverflow.com › questions › 38536786 › multiple-pages-pdf-using-jspdf
html - Multiple pages pdf using jspdf - Stack Overflow
How to save a image in multiple pages of pdf using jspdf · 0 · Create multiple page PDF document jsPDF · 2 · jspdf convert html to pdf with multiple pages · 0 · Is there a way to prevent repeating the same image in all page of pdf using JsPdf · 3 · Multipage pdf with html2Canvas ·
🌐
GitHub
github.com › parallax › jsPDF › issues › 361
addHTML() Multiple Canvas Page · Issue #361 · parallax/jsPDF
September 17, 2014 - You switched accounts on another tab or window. Reload to refresh your session. ... Hi, I noticed already have a release "addHTML() can now split the canvas into multiple pages". May i know how it work? In my case when save as pdf, it just render a single page instead of multiple pages.
Published   Sep 17, 2014
Author   dionlexander
Top answer
1 of 2
3

A simple example using html2pdf plugin:

<script>
    var source = window.document.getElementById("report");

    var pdf = new jsPDF('p', 'pt', 'a4');
    var canvas = pdf.canvas;
    canvas.height = 72 * 11;
    canvas.width = 72 * 8.5;
    //page break
    pdf.context2d.pageWrapYEnabled = true;

    html2pdf(source, pdf, function (pdf) {
                var iframe = document.createElement('iframe');
                iframe.setAttribute('style', 'position:fixed;right:0; top:0; bottom:0; height:100%; width:100%');
                document.body.appendChild(iframe);
                iframe.src = pdf.output('datauristring');
            }
    );
</script>
2 of 2
1

We can create PDF of multiple pages, but create partitions of pages in HTML separated by class

Then we can combine both jsPDF and html2canvas as follow

    var pdf = new jsPDF('p', 'pt', [580, 630]);

    html2canvas($(".page1")[0], {
        onrendered: function(canvas) {
            document.body.appendChild(canvas);
            var ctx = canvas.getContext('2d');
            var imgData = canvas.toDataURL("image/png", 1.0);
            var width = canvas.width;
            var height = canvas.clientHeight;
            pdf.addImage(imgData, 'PNG', 20, 20, (width - 10), (height));

        }
    });
    html2canvas($(".page2")[0], {
        allowTaint: true,
        onrendered: function(canvas) {
            var ctx = canvas.getContext('2d');
            var imgData = canvas.toDataURL("image/png", 1.0);
            var htmlH = $(".page2").height() + 100;
            var width = canvas.width;
            var height = canvas.clientHeight;
            pdf.addPage(580, htmlH);
            pdf.addImage(imgData, 'PNG', 20, 20, (width - 40), (height));
        }
    });
    html2canvas($(".page3")[0], {
        allowTaint: true,
        onrendered: function(canvas) {
            var ctx = canvas.getContext('2d');
            var imgData = canvas.toDataURL("image/png", 1.0);
            var htmlH = $(".page2").height() + 100;
            var width = canvas.width;
            var height = canvas.clientHeight;
            pdf.addPage(580, htmlH);
            pdf.addImage(imgData, 'PNG', 20, 20, (width - 40), (height));
        }
    });
    setTimeout(function() {

        //jsPDF code to save file
        pdf.save('sample.pdf');
    }, 0);

complete tutorial is given here http://freakyjolly.com/create-multipage-html-pdf-jspdf-html2canvas/

🌐
GitHub
github.com › parallax › jsPDF › issues › 159
jsPDF multi page PDF with HTML renderrer · Issue #159 · parallax/jsPDF
July 21, 2013 - Reload to refresh your session. ... Hi I have html page which contain more than one page data and if i generate pdf than it will display only one page pdf please help me for that. My code is function demoFromHTML(element) { var pdf = new jsPDF('p','in','letter') , source = $(element)[0] , specialElementHandlers = { '#bypassme': function(element, renderer){ return true } } pdf.fromHTML( source // HTML string or DOM elem ref.
Published   Dec 21, 2013
🌐
NewbeDEV
newbedev.com › jspdf-multi-page-pdf-with-html-renderer
Sorry, the website has been stopped
The website has been stopped · Sorry, This site has been stopped by the administrator,Please contact the administrator for details
🌐
Py4u
py4u.net › discuss › 933854
Page not found
Page not found The page you're looking for is not found, please go to the main page · Popular Tutorials · Python Data Types · Comparison Operators · Lists In Python · Variable Assignments · Strings In Python · This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 ...