TheBackBencher TheBackBencher - 5 months ago 532
Javascript Question

How to open generated pdf using jspdf in new window

I am using jspdf to generate a pdf file. Every thing is working fine. But how to open generated
pdf in new tab or new window.

I am using

doc.output('datauri');


Which is opening the pdf in same tab.

Answer
  1. Search in jspd.js this:

    if(type == 'datauri') {
        document.location.href ='data:application/pdf;base64,' + Base64.encode(buffer);
    }
    
  2. Add :

    if(type == 'datauriNew') {   
        window.open('data:application/pdf;base64,' + Base64.encode(buffer));
    }
    
  3. call this option 'datauriNew' Saludos ;)
Comments