jsPDF: print a pdf created directly to the printer device

Viewed 3388

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?

1 Answers

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

This option helped me:

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