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

80
Views
Problema de htmlToPdf con saltos de página

Tengo un botón que genera una página html una vez que se hace clic. Este es el fragmento de código de la función onClick

 const doc = new jsdpf('p', 'mm', 'a4'); const downloadPdf = e => { e.preventDefault(); htmlToImage .toPng(document.getElementById('divToPrint1'), { quality: 0.95 }) .then(function (dataUrl) { var link = document.createElement('a'); link.download = 'my-image-name.jpeg'; const imgProps = doc.getImageProperties(dataUrl); var imgWidth = 210; var pageHeight = 295; var imgHeight = (imgProps.height * imgWidth) / imgProps.width; var heightLeft = imgHeight; var position = 10; doc.addImage(dataUrl, 'PNG', 10, position, imgWidth, imgHeight); heightLeft -= pageHeight; while (heightLeft >= 0) { position += heightLeft - imgHeight; // top padding for other pages doc.addPage(); doc.addImage(dataUrl, 'PNG', 0, position, imgWidth, imgHeight); heightLeft -= pageHeight; } doc.save(`sample.pdf`); }); };

la imagen es más larga que un a4, por lo que se generan nuevas páginas, pero el problema es que la imagen se rompe así: imagen

¿Alguna idea de lo que puedo hacer para que la página no se rompa de esta manera?

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!