1. Download adobe reader software and enable it in IE browser
Settings -> Manage Add-ons -> Enable Adobe PDF Reader
2. The HTML code in the Jsp file is as follows
<input type="button" value="打印(P)" onclick="directpdfprint('<%=imgPath_pdf %>')"> <div id="createPDFDIV" style="text-align:center;margin:0 auto;height:1px;width:1px" ></div>
3. Configure the 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 = "CLSID:CA8A9780-280D-11CF-A24D-444553540000"; p.width = 1; p.height = 1; p.src = encodeURI(encodeURI(srcFile));// Process Chinese names pdfprintdiv.appendChild(p); //p.printWithDialog();// Direct printing with print window p.printAll();//Print directly } catch (e) { alert("The adobe reader plugin is not installed, please contact the administrator to install it!"); } } </script>