pdf.js打印

为了使在不同浏览器上打印显示页面一样,最终选择使用pdf.js打印效果。

直接把下载的pdf文件夹放到项目的js目录下

页面上

<a  target="_blank" style="position:absolute;" id="jump"><span></span></a>

<a class="btn btn-primary print_"  href="javascript:;">打印预览</a> 

js部分

$(".print_").click(function(){
  Htjs.dialog.tips("请打印");
  var query=fullContent + "/app/enApplication/static/onlineReadPdf?id="+$("#ids").val();
  window.localStorage.setItem("url_app",query);

  //注意此步的地址要写对
  var url = fullContent + "/js/pdf/generic/web/viewer.html";

  //为了防止浏览器拦截,用此方法
  $("#jump").attr("href",url);
  setTimeout(function(){

  //前面我的文章写的是a标签的点击事件失效解决办法。
  /*document.getElementById('jump').click();*/
  $('#jump span').click();
  },1000);
});

猜你喜欢

转载自www.cnblogs.com/wdd-cindy/p/9844588.html