【发布时间】:2010-11-01 19:37:13
【问题描述】:
我有一个嵌入了 PDF 的网页。我的代码如下所示:
<embed
type="application/pdf"
src="path_to_pdf_document.pdf"
id="pdfDocument"
width="100%"
height="100%">
</embed>
我有这个用于打印我的 PDF 的 javascript 代码:
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 插件会打开众所周知的打印对话框。像这样的:
两个问题:
- 如何改进检测 PDF 已加载并准备好打印的方法?
- 如何避免显示打印对话框?
关于我的系统的更多信息:
操作系统: Windows XP
浏览器: Internet Explorer 7
PDF 插件: Acrobat Reader 9
【问题讨论】:
-
@gideon 出于某种原因这不起作用....在 ie8 ff 或 chrome 中...即给出错误网页错误详细信息消息:'null' 为空或不是对象行:26 Char: 5 Code: 0 URI: localhost/mpdf/pdf.php if i put in alert() if typeof 即使在加载文档后,警报仍会继续弹出
标签: javascript html pdf acrobat