Bali Dave
Bali Dave

Reputation: 161

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

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?

Upvotes: 2

Views: 5949

Answers (3)

Pekka
Pekka

Reputation: 449435

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.

Upvotes: 0

Borealid
Borealid

Reputation: 98469

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.

Upvotes: 0

Sushisource
Sushisource

Reputation: 611

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.

Upvotes: 6

Related Questions