IE 直接打印 頁面的方式

本文轉載於:猿2048網站➧IE 直接打印 頁面的方式javascript

一、 經過在IE中加載adobe pdf reader 插件 進行直接打印和打印的配置 (推薦)
<body>
  <object id="pdf1" width="1000px" height="400px" classid="clsid:CA8A9780-280D-11CF-A24D-444553540000">
  <param name="src" value="../xdoc/testDoc.do">
  </object>
  <script language="JavaScript">
  pdf1.SetShowToolbar (false);
  </script>
  <input type="button" value="打印" onclick="pdf1.printAll()">
  <input type="button" value="打印(帶對話框)" onclick="pdf1.printWithDialog()">
  </body>
 
二、經過  smsx.cab 打印控件進行直接打印
 
 
  <object id="factory" style="display:none" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="smsx.cab#Version=6,3,435,20">
  </object>
  <script type="text/JavaScript">
  function setting () {
 
  if(!factory.object) {
           alert("打印控件沒有正確安裝!");
  return;
  } else {
  factory.printing.header = "";//頁眉
  factory.printing.footer = "";//頁腳
  factory.printing.leftMargin = 1.0;//左邊距
  factory.printing.topMargin = 1.3;//上邊距
  factory.printing.rightMargin = 1.0;//右邊距
  factory.printing.bottomMargin = 1.3;//下邊距
 
  factory.printing.portrait = true;//打印方向,true:縱向.false:橫向
  }
  }
  </script>
  </head>
  <script type="text/javascript">
  function printPDF(){
        factory.printing.Print(true, $("#printIframe")[0].contentWindow.html);
           }
  </script>
  <body onload="setting()">
  <input type="button" value="打印PDF" onclick="printPDF()"/>
  <iframe style="display:block; width:1200px; height:700px;" name="printIframe" id="printIframe"      src="../xdoc/testDoc.do"></iframe>
  </body>
相關文章
相關標籤/搜索