jQuery打印图片pdf和txt

 

<!-- html  -->
<p style="display:none">
<p id="to_print"></p>
<input type="button" id="print_button" value="Print" onclick="document.getElementById('FILEtoPrint').focus(); document.getElementById('FILEtoPrint').contentWindow.print();" />
</p>
 
<script>
//浏览器预览打印
function printSome(path){ //传入文件路径
$("#to_print").html('<iframe src='+path+' id="FILEtoPrint"></iframe>');
  setTimeout(function(){$("#print_button").click();}, 500);
  pagesetup_null();
}

//设置去除页眉页脚
function pagesetup_null() {
  var hkey_root, hkey_path, hkey_key;
  hkey_root = "HKEY_CURRENT_USER";
  hkey_path = "\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";
  try {
    var RegWsh = new ActiveXObject("WScript.Shell");
    hkey_key = "header";
    RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
    hkey_key = "footer";
    RegWsh.RegWrite(hkey_root + hkey_path + hkey_key, "");
  } catch (e) { }
}

 
</script>

 

posted @ 2019-07-12 11:38  程序猿76  阅读(411)  评论(0编辑  收藏  举报