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

390
Vistas
How do I fit the entire content in one page when printing it to PDF?

I am using jspdf and html2canvas. Printing the component would make the footer go to the next page.

How can I set this where it will dynamically resize to fit it on one page when I print it to pdf? Is this possible where the entire component will fit in one page only?

     const generatePdf = () => {
    var doc = new jsPDF("portrait", "pt", "a4");

    doc.html(document.querySelector("#pdf"), {
      html2canvas: {
        scale: 0.5
      },
      callback: function (pdf) {
        pdf.save(`sample.pdf`);
      }
    });
  };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Could you try this, may not be the best solution. Also, note that this will render the HTML as an image and not as text/vector graphics.

const quality = 1 // Higher Quality results in better output
html2canvas(document.querySelector('#html'),
    { scale: quality }
).then(canvas => {
    const pdf = new jsPDF('p', 'mm', 'a4');
    pdf.addImage(canvas.toDataURL('image/png'), 'PNG', 0, 0, 211, 298); // Play around with the metrics here to your liking
    pdf.save(filename);
});

Follow this discussion on GitHub for a better understanding.

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