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

157
Views
pdf creado usando html2cavas y jsPDF obtener el ancho correcto solo en el escritorio?

Tengo el siguiente código, el problema es que la implementación es como si los siguientes elementos generados entraran en un div que tiene un ancho fijo de 1100, usando mui por cierto, al crear el pdf en el escritorio, los resultados son los que deberían ser, sin embargo, al crear el pdf desde el teléfono móvil el ancho del pdf creado es pequeño, podría decir que solo se muestran 400 de los 1100 div, cuando se crea desde Chrome responsive funciona como debería, cómo cuáles son las opciones correctas para hacer que jspdf creó un pdf con el ancho correcto Creo que jsPdf está confundiendo el tamaño de la pantalla del iPhone.

 html2canvas( document.getElementById('pdfItems')!, { onclone: function (clonedDoc) { // none ! hidden show !! clonedDoc.getElementById('pdfItems')!.style.display = 'flex'; }, // TO INCREASE QUALITY !!!!!!!!!! scale: /*3*/ 2, //width: document.getElementById('pdfItems')!.clientWidth, } /* { allowTaint: false, width: window.innerWidth, height: window.innerHeight, scrollX: window.pageXOffset, scrollY: window.pageYOffset, x: window.pageXOffset, y: window.pageYOffset, imageTimeout: 1500, }*/ ).then((canvas) => { //document.body.appendChild(canvas); // if you want see your screenshot in body. const imgData = canvas.toDataURL('image/png'); //A4 var imgWidth = 210; //var pageHeight = 295; var imgHeight = (canvas.height * imgWidth) / canvas.width; //var heightLeft = imgHeight; // A4 var doc = new jsPDF('p', 'mm' /*pt*/, 'a4', true); doc.addPage([imgWidth, imgHeight]); doc.addImage(imgData, 'PNG', 0,0 , imgWidth, imgHeight); doc.deletePage(1); const fileName = 'test' doc.save(`${fileName}.pdf`); }); }; // PDF DIV STYLE <div id='pdfItems' style={{ display: 'flex', flexDirection: 'column', margin: 0, padding: 0, textAlign: 'center', width: 1100, }} > // Itemes </div>

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!