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
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
Share Improve this question edited Aug 11, 2011 at 10:32 midhunhk 5,5547 gold badges55 silver badges84 bronze badges asked Aug 25, 2010 at 9:45 VladimirVladimir 1731 gold badge2 silver badges14 bronze badges 4- possible duplicate of Converting HTML to PDF using PHP? – cweiske Commented Aug 11, 2011 at 10:39
- You mean, as in physically print on paper? Urgh! – Richard H Commented Aug 11, 2011 at 11:18
- This is not exactly the same, but it may help: stackoverflow./questions/6167995/… – yms Commented Aug 11, 2011 at 12:26
- 1 You can't make the browser immediately offer the user the option of printing a PDF file, but you can output a PDF using a method provided by one of the users above. From there the user can opt to click the print button on their own (or choose to open/save the PDF depending on the headers you use). But to directly answer your question, there's no way to do what you want. – Brian Commented Aug 15, 2011 at 19:33
1 Answer
Reset to default 3The 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742362199a4429608.html
评论列表(0条)