Vladimir
Vladimir

Reputation: 173

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

Upvotes: 6

Views: 13266

Answers (1)

Matthew
Matthew

Reputation: 15962

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.

Upvotes: 3

Related Questions