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

100
Views
Why is my JsPdf shoving all elements to the left and making their width small?

When I use jsPDF to generate a pdf of my site, all the elements are shoved to the left and as thin as they can be. I've tried setting width in both the pdf.html() options as well as the html2canvas options inside.

    const doc = new jsPDF({
        orientation: "p",
        format: "legal",
        unit: "px",
        hotfixes: ["px_scaling"]
    });

    const elementHandler = {
        '#ignorePDF': function (element) {
            return false;
        }
    }

    const body = document.getElementsByClassName("content")[0];
    
    doc.html(body.parentElement, {
        autoPaging: 'text',
        width: 1000,
        html2canvas: {
            width: 1000,
            windowWidth: 1000
        },
        callback: async function (doc) {
            doc.setLineWidth(1000);
            doc.save("test.pdf")
        },
        elementHandler: elementHandler
    });

This generates a pdf that looks like this:

messed up pdf

Thank you in advance.

about 4 years ago · Juan Pablo Isaza
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!