进一步讨论在 ASP 页面中如何设置IE浏览器打印“页面设置”!

ruonaner 2004-09-21 12:03:17
在页面打印中直接采用IE浏览器打印,现在用户提出新的要求:在程序中设置打印的纸张大小。我参考了http://www.meadroid.com/scriptx/docs/printdoc.htm?static文档:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>print</title>
</head>
<body>
<!-- MeadCo Security Manager -->
<object viewastext style="display:none"
classid="clsid:5445be81-b796-11d2-b931-002018654e2e"
codebase="smsx.cab#Version=6,1,432,1">
<param name="GUID" value="{67533199-D16A-46D3-BA23-5AA77981F726}">
<param name="Path" value="sxlic.mlf">
<param name="Revision" value="0">
</object>

<!-- MeadCo ScriptX -->
<object id=factory viewastext style="display:none"
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814">
</object>

<script defer>
function window.onload() {
// -- advanced features
factory.printing.SetMarginMeasure(2); // measure margins in inches
factory.printing.printer = "HP DeskJet 870C";
factory.printing.paperSize = "A4";
factory.printing.paperSource = "Manual feed";
factory.printing.collate = true;
factory.printing.copies = 2;
factory.printing.SetPageRange(false, 1, 3); // need pages from 1 to 3

// -- basic features
factory.printing.header = "This is MeadCo";
factory.printing.footer = "Advanced Printing by ScriptX";
factory.printing.portrait = false;
factory.printing.leftMargin = 1.0;
factory.printing.topMargin = 1.0;
factory.printing.rightMargin = 1.0;
factory.printing.bottomMargin = 1.0;
}

function Print(frame) {
factory.printing.Print(true, frame) // print with prompt
}
</script>
<input type=button value="打印本页" onclick="factory.printing.Print(false)">
<input type=button value="页面设置" onclick="factory.printing.PageSetup()">
<input type=button value="打印预览" onclick="factory.printing.Preview()"><br>
<a href="http://www.meadroid.com/scriptx/docs/printdoc.htm?static" target=_blank>具体使用手册,更多信息,点这里</a>
</body>
</html>
但是这个需要注册的控件,不知各位有何高见?除了自己再开发一个类似的控件吗?
...全文
703 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
ruonaner 2004-09-22
  • 打赏
  • 举报
回复
客户的要求就是这样苛刻,能省一步操作就省一步,他们似乎很清楚,只要能想到的,我们作程序的都能实现,客户就是上帝!
shmr 2004-09-21
  • 打赏
  • 举报
回复
学习
cuipi2003 2004-09-21
  • 打赏
  • 举报
回复
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height=0 id=wb name=wb width=0></OBJECT>
<input name="Button" onClick="window.printO.style.display='none';document.all.wb.ExecWB(7,1);" type="button" value="打印预览">
guoweidong 2004-09-21
  • 打赏
  • 举报
回复
(1)<script defer>
function SetPrintSettings() {
 // -- advanced features
 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"
 factory.printing.paperSource = "Manual feed"

 // -- basic features
 factory.printing.header = "This is MeadCo"
 factory.printing.footer = "Advanced Printing by ScriptX"
 factory.printing.portrait = false
 factory.printing.leftMargin = 1.0
 factory.printing.topMargin = 1.0
 factory.printing.rightMargin = 1.0
 factory.printing.bottomMargin = 1.0
}
</script>

(2)
<script language="javascript">
  function printsetup(){
  // 打印页面设置
  wb.execwb(8,1);
  }
  function printpreview(){
  // 打印页面预览
    
  wb.execwb(7,1);
     
    
  }

  function printit()
  {
  if (confirm('确定打印吗?')) {
  wb.execwb(6,6)
  }
  }
  </script>
</head>
<body>
<OBJECT classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"

height=0 id=wb name=wb width=0></OBJECT>
<input type=button name=button_print value="打印"

onclick="javascript:printit()">
<input type=button name=button_setup value="打印页面设置"

onclick="javascript:printsetup();">
<input type=button name=button_show value="打印预览"

onclick="javascript:printpreview();">
<input type=button name=button_fh value="关闭"

onclick="javascript:window.close();">
shootarrow 2004-09-21
  • 打赏
  • 举报
回复
做OA肯定会遇到的问题,打印设置
学习ING
AVAmyZ 2004-09-21
  • 打赏
  • 举报
回复
找个注册码!
ruonaner 2004-09-21
  • 打赏
  • 举报
回复
在尝试中......
ruonaner 2004-09-21
  • 打赏
  • 举报
回复
to:guoweidong(※『孤独~寂)
我这样理解是否有误?
在浏览器浏览你上边写的网页中,可以点击“页面设置”按钮或“打印预览”按钮进行页面设置,在这里可以手动选择“纸张大小”;但如何在脚本中设置“纸张大小”呢?
还请你指点,在此诚挚感谢您的帮助!

guoweidong 2004-09-21
  • 打赏
  • 举报
回复
<html>
<head>
<meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
<title>看看</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--media=print 这个属性可以在打印时有效-->
<style media=print>
.Noprint{display:none;}
.PageNext{page-break-after: always;}
</style>

<style>
.tdp
{
border-bottom: 1 solid #000000;
border-left: 1 solid #000000;
border-right: 0 solid #ffffff;
border-top: 0 solid #ffffff;
}
.tabp
{
border-color: #000000 #000000 #000000 #000000;
border-style: solid;
border-top-width: 2px;
border-right-width: 2px;
border-bottom-width: 1px;
border-left-width: 1px;
}
.NOPRINT {
font-family: "宋体";
font-size: 9pt;
}

</style>

</head>

<body >
<center class="Noprint" >
<p>
<OBJECT id=WebBrowser classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0 width=0>
</OBJECT>
<input type=button value=打印 onclick=document.all.WebBrowser.ExecWB(6,1)>
<input type=button value=直接打印 onclick=document.all.WebBrowser.ExecWB(6,6)>
<input type=button value=页面设置 onclick=document.all.WebBrowser.ExecWB(8,1)>
</p>
<p> <input type=button value=打印预览 onclick=document.all.WebBrowser.ExecWB(7,1)>
<br/>
</p>
<hr align="center" width="90%" size="1" noshade>
</center>

<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
<tr>
<td colspan="3" class="tdp">第1页</td>
</tr>
<tr>
<td width="29%" class="tdp"> </td>
<td width="28%" class="tdp"> </td>
<td width="43%" class="tdp"> </td>
</tr>
<tr>
<td colspan="3" class="tdp"> </td>
</tr>
<tr>
<td colspan="3" class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" class="tdp"><p>这样的报表</p>
<p>对一般的要求就够了。</p></td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
<hr align="center" width="90%" size="1" noshade class="NOPRINT" >
<!--分页-->
<div class="PageNext"></div>
<table width="90%" border="0" align="center" cellpadding="2" cellspacing="0" class="tabp">
<tr>
<td class="tdp">第2页</td>
</tr>
<tr>
<td class="tdp">看到分页了吧</td>
</tr>
<tr>
<td class="tdp"> </td>
</tr>
<tr>
<td class="tdp"> </td>
</tr>
<tr>
<td class="tdp"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50%" class="tdp"><p>这样的报表</p>
<p>对一般的要求就够了。</p></td>
<td> </td>
</tr>
</table></td>
</tr>
</table>
</body>
</html>


guoweidong 2004-09-21
  • 打赏
  • 举报
回复
打印页面不是有纸张设置大小吗?
ruonaner 2004-09-21
  • 打赏
  • 举报
回复
to guoweidong(※『孤独~寂) :
你的第一种方法和我提供的方法好像一样吧,还是我的理解有误?
ruonaner 2004-09-21
  • 打赏
  • 举报
回复
to guoweidong(※『孤独~寂) :
你的第二种方法如何设置纸张的大小?

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧