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

441
Views
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 answers
Answer question

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 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!