...

View Full Version : Opening the Printer Dialog box to print a PDF



CitznFish
05-25-2005, 10:43 PM
This can't be difficult, but i can't seem to find any info on how to do this.

I would like to have a link that opens the Printer Dialog box so a PDF can be printed. This is without opening the PDF at all, but printing out the PDF on a printer. Can this be done?


TIA!

P.S. I bet it's so simple I'm going to slap myself...

martin_narg
05-26-2005, 12:10 AM
Edit:
I stand corrected. Nice one Glennv :thumbsup:



<input type="button" value="Print" name="btnPrint" id="btnPrint" onclick="window.print();">


this would print the html page the button resides on.

It's untested, but if you had something like:


<iframe src="myDocument.pdf" id="myIframe"></iframe>
<input type="button" value="Print" name="btnPrint" id="btnPrint" onclick="document.getElementById("myIframe").print();">


It should print the content of that window/frame.

hope this helps

m_n

glenngv
05-26-2005, 05:37 AM
http://www.dynamicdrive.com/dynamicindex9/printstyle.htm

CitznFish
05-26-2005, 07:04 PM
http://www.dynamicdrive.com/dynamicindex9/printstyle.htm
IE only. :(

glenngv
05-27-2005, 05:00 AM
At the moment, you have to make do with a workaround.

Load the PDF in a hidden iframe. That will confuse users though as the Acrobat splash screen will show up even if they won't see a PDF file.


function printPDF(){
var pdf = document.getElementById("pdfDoc").contentWindow;
pdf.focus();
pdf.print();
}
...
<iframe src="myDocument.pdf" id="pdfDoc" style="display:none"></iframe>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum