I have a web page with embedded PDF on it. My code looks like this:
<embed
type="application/pdf"
src="path_to_pdf_document.pdf"
id="pdfDocument"
width="100%"
height="100%">
</embed>
I have this javascript code for print my PDF:
function printDocument(documentId) {
//Wait until PDF is ready to print
if (typeof document.getElementById(documentId).print == 'undefined') {
setTimeout(function(){printDocument(documentId);}, 1000);
} else {
var x = document.getElementById(documentId);
x.print();
}
}
When this code is executed Acrobat plug-in opens the well-known print dialog. Something like this:
Two questions:
- How to improve the way to detect that PDF is loaded and ready for print?
- How to avoid showing print dialog?
A little more info about my system:
OS: Windows XP
Browser: Internet Explorer 7
PDF Plugin: Acrobat Reader 9