jQuery打印图片pdf、txt示例代码
html加如下代码
<divstyle="display:none"> <divid="to_print"></div> <inputtype="button"id="print_button"value="Print"onclick="document.getElementById('FILEtoPrint').focus();document.getElementById('FILEtoPrint').contentWindow.print();"/> </div> <script> functionprintSome(path){//传入文件路径 $("#to_print").html('<iframesrc='+path+'id="FILEtoPrint"></iframe>'); setTimeout(function(){$("#print_button").click();},500); } </script>
web界面添加按钮调用js即可