PDF顯示插件

1. ie瀏覽器適用
<object id="pdf_panel" class="pdf-panel" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000"> <param name="_Version" value="327680" />
  <param name="_ExtentX" value="0" />
  <param name="_ExtentY" value="0" />
  <param name="_StockProps" value="0" />
  <param name="SRC" value="" />
  <embed width="100%" height="90%">
    <noembed>打開PDF文檔失敗, 原因是您的瀏覽器不支持PDF或您的電腦未安裝PDF文檔閱讀器</noembed>
  </embed>
</object>
//添加文件路徑
function
showPdf() {
  //IE
  document.all("pdf_panel").src = url/Path; }

 1.2 ie打印PDF文件

 function printPdf() {
  var pdfControl = document.getElementById("pdf_panel");
  if (pdfControl != null && pdfControl.printWithDialog)
    pdfControl.printWithDialog();
}
2. Chrome 和 Firefox瀏覽器使用
<embed width="100%" height="90%" id="pdf-plugin" name="plugin" type="application/pdf"></embed>
function showPdf() {
  //Chrome\Firefox
  document.getElementById("pdf-plugin").setAttribute("src", url/path);
}
2.1 打印pdf事件--Chrome
<iframe id="pdfPrint" class="hdFrame" src="url/path" ></iframe>
function printPdf() {
  document.getElementById("pdfPrint").contentWindow.print();
} 

 3.在敲字之前,我在网站搜索了相关内容,看了好多篇文章,学习到了不少,简单地在这总结一下。也记录下个人看过的觉得比较好的链接(参考1,参考2)

猜你喜欢

转载自www.cnblogs.com/2625664742-chanyk/p/11306905.html