| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 598 人关注过本帖
标题:求助:asp控制web页面打印
只看楼主 加入收藏
无心睡眠
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-3-18
收藏
 问题点数:0 回复次数:0 
求助:asp控制web页面打印
最近在做一个快递单打印功能.
在网上找了很多关于web页面打印控制的代码,都无法实现我想要的效果.

以下是采用网上的一段控制页眉,页脚,和边距的代码,使用针式打印机打印效果不怎么好,老是无法控制位置,有时能准确的印在快递单上.

请教各位高手,帮帮忙,万分感谢.


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=Title%></title>
<script defer>      
function SetPrintSettings(){     
  try   
  {   
    factory.printing.SetMarginMeasure(2) //measure margins in inches      
    factory.SetPageRange(false, 1, 3) //     need     pages     from     1     to     3      
    factory.printing.printer = "HP DeskJet 870C"      
    factory.printing.copies = 2
    factory.printing.collate = true
    factory.printing.paperSize = "A4"       //A3在这里修改   
    factory.printing.paperSource = "Manual feed"      
    //     --     basic     features      
    factory.printing.header = ""
    factory.printing.footer = ""
    factory.printing.portrait = false
    factory.printing.leftMargin = 32
    factory.printing.topMargin = 6.5
    factory.printing.rightMargin = 0
    factory.printing.bottomMargin = 0
  }   
  catch(e)   
  {}   
}      
</script>      
<script language="javascript">
/*
function printsetup(){
    factory.execwb(8,1);
}      
function printpreview(){
    factory.execwb(7,1);      
}
*/
function printit(){
    bdhtml=window.document.body.innerHTML;  
    sprnstr="<!--startprint-->";
    eprnstr="<!--endprint-->";
    prnhtml=bdhtml.substr(bdhtml.indexOf(sprnstr)+17);
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));
    window.document.body.innerHTML=prnhtml;
    SetPrintSettings();
    window.print();
}      
</script>
</head>
<body>
<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=factory name=factory width=0></object>
<!--startprint-->
<table border="0" width="750px" cellspacing="0" cellpadding="0">
  <tr>
     <td height="40px" colspan="4"></td>
  </tr>
  <tr>
    <td width="170px"></td>
    <td valign="top">    
        <table align="left" border="0" width="250" cellspacing="0" cellpadding="2" style="font-size:12.5pt;font-family: 宋体">
          <tr>
            <td height="30px">&nbsp;&nbsp;<%=SupContactName%></td>
          </tr>
          <tr>
            <td height="12px" valign="top"></td>
          </tr>
          <tr>
            <td height="45px" valign="top" style="line-hieght:130%;">&nbsp;&nbsp;<%=SupAddress%></td>
          </tr>
          <tr>
            <td height="30px">&nbsp;&nbsp;<%=SupCompanyName%></td>
          </tr>
          <tr>
            <td height="40px">&nbsp;&nbsp;<%=SupTelephone%></td>
          </tr>
        </table>
    </td>
    <td width="90px"></td>
    <td valign="top">    
        <table align="left" border="0" width="100%" cellspacing="0" cellpadding="2" style="font-size:12.5pt;font-family: 宋体">
          <tr>
            <td height="30px">&nbsp;&nbsp;<%=DeliverContactName%></td>
          </tr>
          <tr>
            <td height="12px" valign="top"></td>
          </tr>
          <tr>
            <td height="45px" valign="top" style="line-hieght:130%;">&nbsp;&nbsp;<%=DeliverAddress%></td>
          </tr>
          <tr>
            <td height="30px">&nbsp;&nbsp;<%=DeliverCompanyName%>(电话:<%=DeliverTelephone%>)</td>
          </tr>
          <tr>
            <td height="40px">&nbsp;&nbsp;<%=DeliverTelephone%></td>
          </tr>
        </table>
    </td>
  </tr>
</table>
<!--endprint-->
<table align="center" border="0" width="200" cellspacing="0" cellpadding="0">
  <tr>
     <td align="center" height="60"><img src="../Images/print.jpg" align="absmiddle" style="cursor:hand;" onClick="printit();"></td>
  </tr>
</table>
</body>
</html>
搜索更多相关主题的帖子: web页面 快递 针式打印机 asp 
2008-03-18 11:45
快速回复:求助:asp控制web页面打印
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.011634 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved