Silent print an embedded PDF

前端 未结 4 1856
忘了有多久
忘了有多久 2020-11-27 03:38

I have a web page with embedded PDF on it. My code looks like this:



        
相关标签:
4条回答
  • 2020-11-27 04:03

    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.

    0 讨论(0)
  • 2020-11-27 04:08

    This is possible in a trusted, Intranet environment.

    <object id="pdfDoc" style="position:absolute;z-index:-1;" name="pdfDoc" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000" width="900px" height="100%">
            <param name="SRC" value="yourdoc.pdf" />
        </object>
    
    <input type="button" ... onclick="pdfDoc.printAll();" />
    

    This will bypass the print dialog and send directly to the default printer.

    0 讨论(0)
  • 2020-11-27 04:08

    I wonder if you actually need to wait before printing -- won't the print job handle that for you? And I truly hope no modern browser will allow you (or any website for that matter) to print without that confirmation dialog (some old browsers used to do that, a long time ago).

    0 讨论(0)
  • 2020-11-27 04:18

    You can do this in Firefox by changing about:config. Add print.always_print_silent and set it to true.

    0 讨论(0)
提交回复
热议问题