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.
Based on the source you can use the 'dataurlnewwindow' parameter for output():
doc.output('dataurlnewwindow');
Source in github: https://github.com/MrRio/jsPDF/blob/master/jspdf.js#L914
All possible cases:
doc.output('save', 'filename.pdf'); //Try to save PDF as a file (not works on ie before 10, and some mobile devices) doc.output('datauristring'); //returns the data uri string doc.output('datauri'); //opens the data uri in current window doc.output('dataurlnewwindow'); //opens the data uri in new window
I have to use this to load the PDF directly. Using doc.output('dataurlnewwindow');
produces an ugly iframe for me. Mac/Chrome.
var string = doc.output('datauristring'); var x = window.open(); x.document.open(); x.document.location=string;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With