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

436
Vistas
jsPDF output('dataurlnewwindow') not working when attaching more than 4 images of 300 KB

I'm having an issue when trying to do a preview of a PDF file generated using jsPDF API, when I add more than 3 images to the document (each one of 300-400KB) I can download the document correctly, but I cannot display it in the browser using the jsPDF method: doc.output('dataurlnewwindow'). A new tab is being opened on my web browser but it's blank (and at the top of the tab it states "charging..." but its never displayed. However, I can download the PDF file without any issue to my PC using jsPDF method: doc.save( this.reportFileName );

Do you have any idea of why this is happening? could be an issue related to the size of the PDF file that I need to preview in the web browser? is there any maximum size for doing this? Any help would be really appreciated.

Thanks!

this.doc = new jsPDF({orientation: "p", unit: "pt", format: "a4"}) 
// ....
// doing some stuff in the doc file
// adding images of 400 KB aprox. (it works with 3 images... but with 4 or more doesn't
this.doc.addImage('data:image/jpeg;base64,'+ logoFooter, 'JPEG', this.marginLeft+40, 794, 40, 45);
// ....

    preview () { 
      try {
        this.doc.output('dataurlnewwindow'); // >> doesn't work and an empty tab is being opened in muy web browser
        
      }
      catch(error){
         console.log(error);
      }

 save () { 
      try {
        this.doc.save( this.reportFileName ); // this works fine and the PDF file is being downloaded
      }
      catch(error){
        console.log(error);
    },

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

well, I found the solution here: https://github.com/parallax/jsPDF/issues/300#issuecomment-49363483

summary... doing the following:

var blob = this.doc.output("blob");
window.open(URL.createObjectURL(blob));

thanks for your help!

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