Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autoprint PDF script on php or javascript

I want to build a page that will automatically print a pdf document. For example I can call mypage.html?doc=my.pdf and it will print my.pdf file.

How I can do it using javascript or php?

Vladimir

like image 694
Vladimir Avatar asked Aug 25 '10 09:08

Vladimir


1 Answers

The closest you can get to what you want is to embed an iframe containing the PDF in an HTML page, then call window.print when the iframe has loaded.

...
<iframe src="path/to/file.pdf" onload="window.print()"></iframe>
...

This will open the standard print dialog on most browsers.

like image 61
Matthew Avatar answered Sep 28 '22 08:09

Matthew