Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

94
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda