无声打印嵌入式PDF [英] Silent print an embedded PDF
问题描述
我有一个嵌入了PDF的网页。我的代码如下所示:
< embed
type =application / pdf
src = path_to_pdf_document.pdf
id =pdfDocument
width =100%
height =100%>
< / embed>
我有这个用于打印我的PDF的JavaScript代码:
函数printDocument(documentId){
//等待PDF准备打印
if(typeof document.getElementById(documentId))。 print =='undefined'){
setTimeout(function(){printDocument(documentId);},1000);
} else {
var x = document.getElementById(documentId);
x.print();
执行此代码时,Acrobat插件将打开众所周知的打印对话框。像这样:
两个问题:
:
操作系统: Windows XP
浏览器 Internet Explorer 7
PDF插件:Acrobat Reader 9
您无法使用普通的旧JavaScript进行无声打印。您希望您的打印机如何开始打印100万页全黑页面。不是一件好事。如果您想静默打印并且仅适用于Internet Explorer,则可以使用ActiveX控件。这需要您的网页和您的用户更高的安全设置才能真正信任您的网站。
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
You are not going to be able to print silently with plain old JavaScript. How would you like your printer to start printing out 100000000 pages of all black. Not a good thing. If you want to print silently and have it work for Internet Explorer only, there are ActiveX controls out there that can do it. This requires higher security settings for your page and for your users to really trust your site.
这篇关于无声打印嵌入式PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!