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

769
Views
JsPDF: Error (archivo png incompleto o corrupto)

Estoy tratando de agregar un logotipo e intenté agregar una imagen, pero al imprimirla se mostrará este error:

 Incomplete or corrupt PNG file

¿Cómo puedo solucionar esto?

Recreé el problema aquí: https://codesandbox.io/s/js-pdf-with-data-printable-from-displayed-data-lup6ir?file=/src/App.js

 const handlePrint = () => { console.log("clicked"); const doc = new jsPDF(); var img = new Image(); img.src = "assets/logo-social.png"; doc.addImage(img, "png", 10, 78, 12, 15); doc.text("Title here", 20, 10); doc.text("Sample", 20, 15); const columns = ["Data"]; const rows = []; data.map((item) => rows.push([ item.cartItems.map( (item) => `${item.name}: ${item.color} = ${item.quantity}` ) ]) ); doc.autoTable(columns, rows); doc.save("order.pdf"); };
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

La imagen no está completamente cargada en el momento de su uso en doc.addImage . Espere a que la imagen se cargue por completo y luego llame a addImage .

 const img = new Image(); img.src = 'image-url'; img.onload = () => { // await for the image to be fully loaded doc.addImage(img,'png',...); doc.text("Sample", 20, 15); //... doc.save('order.pdf'); };
about 4 years ago · Juan Pablo Isaza Report
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!