无声打印嵌入式PDF [英] Silent print an embedded PDF

查看:148
本文介绍了无声打印嵌入式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插件将打开众所周知的打印对话框。像这样:





两个问题:


  • 如何改进检测PDF的方式打印?

  • 如何避免显示打印对话框?





操作系统: 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆