我有一个包含嵌入式PDF的网页。我的代码看起来像这样:
<embed
type="application/pdf"
src="path_to_pdf_document.pdf"
id="pdfDocument"
width="100%"
height="100%">
</embed>
我有这段JavaScript代码用于打印我的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();
}
}
当执行此代码时,Acrobat插件会打开常见的打印对话框,类似于这样:
两个问题:1. 如何改进检测PDF是否已加载并准备好进行打印的方式? 2. 如何避免显示打印对话框?
有关我的系统的更多信息: 操作系统:Windows XP 浏览器:Internet Explorer 7 PDF插件:Acrobat Reader 9