web|web打印|动态|网页这篇文章主要介绍了如何使用ASP控制Web的各种打印效果,它能够控制纵打、横打和页面边距等。
1、控制"纵打"、"横打"和"页面的边距"。
(1)
<scriptdefer>
functionSetPrintSettings(){
//--advancedfeatures
factory.printing.SetMarginMeasure(2)//measuremarginsininches
factory.SetPageRange(false,1,3)//needpagesfrom1to3
factory.printing.printer="HPDeskJet870C"
factory.printing.copies=2
factory.printing.collate=true
factory.printing.paperSize="A4"
factory.printing.paperSource="Manualfeed"
//--basicfeatures
factory.printing.header="ThisisMeadCo"
factory.printing.footer="AdvancedPrintingbyScriptX"
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)
<scriptlanguage="javascript">
functionprintsetup(){
//打印页面设置
wb.execwb(8,1);
}
functionprintpreview(){
//打印页面预览
wb.execwb(7,1);
}
functionprintit()
{
if(confirm('确定打印吗?')){
wb.execwb(6,6)
}
}
</script>
</head>
<body>
<OBJECTclassid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"
height=0id=wbname=wbwidth=0></OBJECT>
<inputtype=buttonname=button_printvalue="打印"
onclick="javascript:printit()">
<inputtype=button name=button_setupvalue="打印页面设置"
onclick="javascript:printsetup();">
<inputtype=button name=button_showvalue="打印预览"
onclick="javascript:printpreview();">
<inputtype=buttonname=button_fhvalue="关闭"
onclick="javascript:window.close();">
------------------------------------------------
关于这个组件还有其他的用法,列举如下:
WebBrowser.ExecWB(1,1)打开
Web.ExecWB(2,1)关闭现在所有的IE窗口,并打开一个新窗口
Web.ExecWB(4,1)保存网页
Web.ExecWB(6,1)打印
Web.ExecWB(7,1)打印预览
Web.ExecWB(8,1)打印页面设置
Web.ExecWB(10,1)查看页面属性
Web.ExecWB(15,1)好像是撤销,有待确认
Web.ExecWB(17,1)全选
Web.ExecWB(22,1)刷新
Web.ExecWB(45,1)关闭窗体无提示
2、分页打印
<HTML>
<HEAD>
<STYLE>
P{page-break-after:always}
</STYLE>
</HEAD>
<BODY>
<%whilenotrs.eof%>
<P><%=rs(0)%></P>
<%rs.movenext%>
<%wend%>
</BODY>
</HTML>
3、ASP页面打印时如何去掉页面底部的路径和顶端的页码编号
(1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。
(2)
<HTML>
<HEAD>
<TITLE>NewDocument</TITLE>
<METANAME="Generator"CONTENT="EditPlus">
<METANAME="Author"CONTENT="YC">
<scriptlanguage="VBScript">
dimhkey_root,hkey_path,hkey_key
hkey_root="HKEY_CURRENT_USER"
hkey_path="\Software\Microsoft\InternetExplorer\PageSetup"
'//设置网页打印的页眉页脚为空
functionpagesetup_null()
onerrorresumenext
SetRegWsh=CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWritehkey_root+hkey_path+hkey_key,""
hkey_key="\footer"
RegWsh.RegWritehkey_root+hkey_path+hkey_key,""
endfunction
'//设置网页打印的页眉页脚为默认值
functionpagesetup_default()
onerrorresumenext
SetRegWsh=CreateObject("WScript.Shell")
hkey_key="\header"
RegWsh.RegWritehkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"
hkey_key="\footer"
RegWsh.RegWritehkey_root+hkey_path+hkey_key,"&u&b&d"
endfunction
</script>
</HEAD>
<BODY>
<br/>
<br/>
<br/>
<br/>
<br/>
<br/><palign=center>
<inputtype="button"value="清空页码"onclick=pagesetup_null()><inputtype="button"value="恢复页吗"onclick=pagesetup_default()><br/>
</p>
</BODY>
</HTML>
4、浮动帧打印
<SCRIPTLANGUAGE=javascript>
functionbutton1_onclick(){
varodoc=window.iframe1.document;
ASP动态网页开发中的WEB打印代码大全
80酷酷网 80kuku.com