use Acrobat Reader DC js api print pdf; IE 8+ in JS call adobe reader to print a PDF document

https://blog.csdn.net/fujiang3673/article/details/80065862

1. Download adobe reader software, and enable the IE browser

    Settings -> Manage Add-ons -> Enable Adobe PDF Reader

2. Jsp file in HTML code as follows

<input type="button" value="打印(P)" οnclick="directpdfprint('<%=imgPath_pdf %>')">
<div id="createPDFDIV" style="text-align:center;margin:0 auto;height:1px;width:1px" ></div>

3. Configure JS method

<script type="text/javascript">
function directpdfprint(srcFile) {
    var pdfprint = document.getElementById("createPDF");
    if (pdfprint != undefined && pdfprint != null) {
        var parentNode = pdfprint.parentNode;
        parentNode.removeChild(pdfprint);
    }
    var pdfprintdiv = document.getElementById("createPDFDIV");
    
    var p = document.createElement("object");
    try {
        p.id = " CreatePDF " ; 
        p.classid = " the CLSID: CA8A9780-280D-11CF-A24D-444553540000 " ; 
        p.width = . 1 ; 
        p.height = . 1 ; 
        p.src = the encodeURI (the encodeURI (srcFile)); // process Chinese name 
        pdfprintdiv.appendChild (P);
         // p.printWithDialog (); // tape printing direct printing window 
        p.printAll (); // direct printing 
    } the catch (E) { 
        Alert ( " not installed adobe reader plug, Please contact the administrator to install! " );  
    }
}
</script>

 

Guess you like

Origin www.cnblogs.com/Tom-yi/p/11276133.html