I try to print pdf file in javaScript. I get the file's url from the server.
var iframe = document.createElement('iframe');
document.body.appendChild(iframe);
iframe.style.display = 'none';
iframe.src = urlBaseImage + 'Report//' + result;
iframe.focus();
iframe.contentWindow.print();
But he give me empty page, I checked the url and it is really correct. What Can I do? Thanks!
You can use this library, Print.js: http://printjs.crabbly.com/
It is very easy to print PDF files with it.
Just pass the PDF file url to the printJS() function;
For example:
printJS('docs/my_pdf_file.pdf');
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