简体   繁体   中英

jsPDF: print a pdf created directly to the printer device

In my "classic ASP" code I can dynamically create a PDF using jsPDF (JavaScript PDF Creator) Library:

var doc = new jsPDF();
var name = "Smith, John"
doc.setFontType("normal");
doc.setFontSize(12);
doc.text(20,20,'Name: '+ name);
doc.save("filename.pdf");    
doc.autoPrint();

Now if I put this code in my ASP page the.PDF will saved but not printed.

Using the online snippet (like https://veryutils.com/demo/jspdf/ ), my script works, but works only choosing AUTOPRINT in the combobox. This mean that some JS or library is added choosing AUTOPRINT.

Starting from a new page, which.JS I have to "connect" to allow .autoprint method?

You can try using this option by playing with the keys from the jspDF documentation

This option helped me:

doc.autoPrint();
doc.output('dataurlnewwindow');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM