Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

442
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda