I am trying to open a local pdf file and print it.It works for files upto 5 kb,but it takes time to load for big files within 1000ms and hangs.I want it to be dynamic and need not fix the timeout . I tried window.onload but it does not work.Also i dont want to add any onload event to the printing page.
Is there a efficient solution
var win=window.open(printUrl);
setTimeout(function() {
win.print();
win.close();
}, 1000);
Found an workaround for this.Have used PDF Javascripts and embedded a Javascript to print the file.This makes sure that the file is only printed once the page has been loaded.
I had used PDFbox to parse PDF contents and added the below:
PDActionJavaScript javascript = new PDActionJavaScript("this.print();");
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