Search code examples
javascriptjspdf

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.


Solution

    1. Search in jspdf.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 ;)