Tutorial :Need a print button in a browser that will print a PDF file



Question:

I need to set up a print button in HTML that will print a certain PDF file, hopefully without having to download the file first. I've tried a few things but some only work in IE. and some require downloading the file as an embedded object which also is not acceptable. Embedding javascript in the PDF sounds the most promising, but I'd rather avoid that if possible for other reasons.

Any other ideas?


Solution:1

Unfortunately it really can't be done... PDFs are not handled naively by any browser, and as is such they can't be printed using the browser's print dialog.

Your users will have to download the pdf and print it with whatever PDF software they use (Even if it's just a plugin for the browser) unless you convert it to boring old html or an image or something.


Solution:2

You cannot print something without the user downloading it first.

The printer is located on the user end of the connection. The PDF is, at first, located on the server end.

The PDF must thus travel across the webs to reach the user end before the printer will know which ink to put on paper. In other words, it must be downloaded.


Solution:3

I think the best you can do is download the PDF into an iframe element, and advise the user to click the "print" button in there. To my knowledge, no tighter integration than that is possible. The PDF viewer's print button can not be accessed via JavaScript.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »