页面打印js方法

<#import "/WEB-INF/shtml/framework/until/common.ftl" as common>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

  <head>

    

    <title>打印页面</title>

    <#include "/WEB-INF/shtml/framework/ini/header.shtml"> 

    <script type='text/javascript' src='${common.contentPath}/ajax/util.js'></script>

<style media="print" type="text/css"> 

.tab{display:none;} 

.PageNext{page-break-after: always;}

.tabPrint td

height:5px; 

listTab{ background-color:#fff; margin:10px 3px 3px 0px; border:1px #333 solid; border-collapse:collapse; font-size:12px; }

.listTab th{height:54px; border:1px #333 solid;  font-weight:normal; line-height:24px; white-space:nowrap; padding:4px;}

.listTab td{ height:54px;border:1px #333 solid; padding:0 10px 0 10px; border-collapse:collapse;}

big{ font-size:14px; padding:5px; font-weight:bold;}

</style> 

<style media="screen">

.listTab{ background-color:#fff; margin:10px 3px 3px 0px; border:1px #333 solid; border-collapse:collapse; font-size:12px; }

.listTab th{height:54px; border:1px #333 solid;  font-weight:normal; line-height:24px; white-space:nowrap; padding:4px;}

.listTab td{ height:54px;border:1px #333 solid; padding:0 10px 0 10px; border-collapse:collapse;}

big{ font-size:14px; padding:5px; font-weight:bold;}

</style>

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

<%

List tagsList = (List) request.getAttribute("newTagsList");

%>

  </head>

  <script type="text/javascript">

  var HKEY_Root,HKEY_Path,HKEY_Key;

HKEY_Root="HKEY_CURRENT_USER";

HKEY_Path="\\Software\\Microsoft\\Internet Explorer\\PageSetup\\";

function print(){

var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';

document.body.insertAdjacentHTML('beforeEnd', WebBrowser); 

SetupPage();

//SetupLandscape();

WebBrowser1.ExecWB(7,1);

//打印

    //WebBrowser1.ExecWB(6,6);

//WebBrowser.execwb(6,6);

//alert("1111");

}

//设置纸张方向 

function SetupLandscape() 

    try{ 

  var wsShell= new ActiveXObject("WScript.Shell"); 

  //打印页面的Menubar必须可见,此操作类似按键盘上的Alt+F+U也就是 调出页面设置对话框 

  wsShell.sendKeys('%fu'); 

  //此操作类似按键盘上的Alt+A也就是 设置横向打印 

  wsShell.sendKeys('%a'); 

  //此操作类似按键盘上的回车 页面设置对话框的默认焦点在 确定上 所以直接确定 

  wsShell.sendKeys('{ENTER}'); 

     

      catch(e){} 

//设置页面的页眉和页脚

function SetupPage() 

      try{ 

    var Wsh=new ActiveXObject("WScript.Shell"); 

      HKEY_Key="header"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,""); 

      HKEY_Key="footer"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"制单:&b&b共&P页,第&p页"); 

      HKEY_Key="margin_bottom"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0.39"); 

      HKEY_Key="margin_left"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0.39"); 

      HKEY_Key="margin_right"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0.39"); 

      HKEY_Key="margin_top"; 

      Wsh.RegWrite(HKEY_Root+HKEY_Path+HKEY_Key,"0.39"); 

     

      catch(e){} 

  </script>

  <body>

    <input  type="button" class="tab"  id = "tab" name = "tab" value="打印预览" onclick="print();">

<div style="display:block">

<table  border="0" cellspacing="0" cellpadding="0"  width=100%  class="listTab">

<!--<tr>

<td colspan="6" align="center"><b><h3>广州市社会保障(市民)卡交接清单</h3></b></td>

</tr>

<tr>

<td>客户名称</td>

<td colspan="5">广州市市民服务和社会保障卡管理中心 </td>

</tr>

<tr>

<td width="18%">交接日期</td>

<td>${common.formateDate(req_af.transferdate,"yyyy-MM-dd")}</td>

<td width="10%">交接批次</td>

<td>${common.formateDate(req_af.transferdate,"yyyy-MM-dd")}</td>

<td>本批次数量</td>

<td>${req_af.bitchnum}</td>

</tr>

<tr>

<td>卡片名称  <br />

(卡种类型)</td>

<td colspan="5">广州社保金融卡</td>

</tr>

<tr>

<td>区名称及代码</td>

<td colspan="5">天河区     440107</td>

</tr>

<tr >

<td rowspan="3">全业务服务网点</td>

</tr>

<tr>

<td colspan="2">日常业务服务网点</td>

</tr>

<tr>

<td>名称</td>

<td>箱数</td>

</tr>

<tr>

<td rowspan="3">全业务服务网点名称-箱号</td>

</tr>

<tr>

<td >天河区级管理  4401070505</td>

<td > 穗园网点  050544</td>

<td > 2</td>

</tr>

<#if binlist?size gt 0>

<tr>

<td align="center" width="15%">箱号</td>

<td align="center" width="15%" >数量</td>

<td align="center" width="15%">盒号</td>

<td align="center" width="15%">数量</td>

<td align="center">备注</td>

<td align="center"></td>

</tr>

<#list boxlist as listbox>

<tr>

<td rowspan="${boxlist[listbox_index].boxvo?size+1}" align="center">${listbox.binno}</td>

<td rowspan="${boxlist[listbox_index].boxvo?size+1}" align="center">${listbox.allnum}</td>

</tr>

<#list boxlist[listbox_index].boxvo as boxvo>

<tr>

<td align="center">${boxvo.boxno}</td>

<td align="center">${boxvo.storagecount}</td>

<td align="center">${boxvo.remark}</td>

</tr>

</#list>  

</#list>

</#if>

 

--><!-- 

<tr>

<td align="center" width="15%">箱号</td>

<td align="center" width="15%" >数量</td>

<td align="center" width="15%">盒号</td>

<td align="center" width="15%">数量</td>

<td align="center">备注</td>

</tr>

<tr>

<td rowspan="3" align="center">10001</td>

<td rowspan="3" align="center">300</td>

<td align="center">HSJRK1000101</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

<tr>

<td align="center">HSJRK1000102</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

<tr>

<td align="center">HSJRK1000103</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

<tr>

<td rowspan="3" align="center">10002</td>

<td rowspan="3" align="center">300</td>

<td align="center">HSJRK1000202</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

<tr>

<td align="center">HSJRK1000202</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

<tr>

<td align="center">HSJRK1000202</td>

<td align="center">100</td>

<td align="center">&nbsp;</td>

</tr>

   --> 

   <tr>

    <td colspan="5" align="center"><b><h3>广州市社会保障(市民)卡交接清单</h3></b></td>

   </tr>

   <tr>

    <td>客户名称</td>

<td colspan="4">广州市市民服务和社会保障卡管理中心 </td>

   </tr>

   <tr>

    <td width="18%">交接日期</td>

<td>${common.formateDate(req_af.transferdate,"yyyy-MM-dd")}</td>

<td width="10%">交接批次</td>

<td>&nbsp;</td>

<td>本批次数量: ${req_af.bitchnum}</td>

   </tr>

   <tr>

    <td>卡片名称  <br />

(卡种类型)</td>

<td colspan="4">广州社保金融卡</td>

   </tr>

   <tr>

    <td>区名称及代码</td>

<td colspan="4">${req_af.regional}</td>

   </tr>

   <tr>

    <td rowspan="2">全业务服务网点</td>

    <td colspan="2">日常业务服务网点</td>

    <td rowspan="2">全服务网点名称-箱号</td>

    <td rowspan="2">日常业务服务网点的卡数量</td>

   

   </tr>

    <tr>

    <td>名称</td>

    <td>箱数</td>>

   </tr>

  

   <tr>

    <td rowspan="${binlist?size+1}"></td>

    <td rowspan="${binlist?size+1}">${req_af.net_name}</td>

    <td rowspan="${binlist?size+1}">${binlist?size}</td>

   </tr>

    <#if binlist?size gt 0>

   <#list boxlist as listbox>

<tr>

<td align="center" width="15%">${listbox.binno}</td>

<td align="center" width="15%" >${listbox.allnum}</td>

</tr>

</#list>

</#if>

   

<tr>

<td>小计:</td>

<td align="center">&nbsp;</td>

<td align="center">&nbsp;</td>

<td align="center">&nbsp;</td>

<td align="center">${req_af.bitchnum}</td>

</tr>

<tr>

<td>备注:</td>

<td colspan="4">&nbsp;</td>

</tr>

</table>

<br>

<br>

<br>

<table width=100%  cellspacing="0" cellpadding="0" class='tabPrint' align="center">

<tr>

<td aligh="left"></td><td></td><td aligh="right"></td>

</tr>

</table>

</div>

  </body>

</html>


你可能感兴趣的:(页面打印js方法)