Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
JSPDF how to modify this code to print two pages instead of one page

I have a script to generate a DIV to PDF but now I have two DIVs and I need to generate a two-pages PDF from this two DIVs

How can I modify this code to do this

The first DIV is the #pdf-one and the second is #pdf-two

public exportHtmlToPDF() {
    let data = document.getElementById('pdf-one')!;

    html2canvas(data).then(canvas => {

      let docWidth = 208;
      let docHeight = canvas.height * docWidth / canvas.width;

      const contentDataURL = canvas.toDataURL("image/jpeg", 1.0);
      let doc = new jsPDF('p', 'mm', 'a4');
      let position = 0;
      doc.addImage(contentDataURL, 'JPG', 0, position, docWidth, docHeight, 'FAST');

      doc.save('test.pdf');
    });
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Try using break-after on your first div, like this:

#pdf-one {
 break-after: always; 
}

More info about break-after you can find here

And of course your div's height should match the height of the pdf page

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!