[p]1、控制"纵打"、 横打”和“页面的边距。[br](1)<script defer>[br]function setprintsettings() {[br]// -- advanced features[br]factory.printing.setmarginmeasure(2) // measure margins in inches[br]factory.setpagerange(false, 1, 3) // need pages from 1 to 3[br]factory.printing.printer = "hp deskjet 870c"[br]factory.printing.copies = 2[br]factory.printing.collate = true[br]factory.printing.papersize = "a4"[br]factory.printing.papersource = "manual feed"[/p]
[p]// -- basic features[br]factory.printing.header = "this is meadco"[br]factory.printing.footer = "advanced printing by scriptx"[br]factory.printing.portrait = false[br]factory.printing.leftmargin = 1.0[br]factory.printing.topmargin = 1.0[br]factory.printing.rightmargin = 1.0[br]factory.printing.bottommargin = 1.0[br]}[br]</script>[/p]
[p](2)[br]<script language="javascript">[br]function printsetup(){[br]// 打印页面设置[br]wb.execwb(8,1);[br]}[br]function printpreview(){[br]// 打印页面预览[/p]
[p]wb.execwb(7,1);[/p]
[p][br]}[/p]
[p]function printit()[br]{[br]if (confirm('确定打印吗?')) {[br]wb.execwb(6,6)[br]}[br]}[br]</script>[br][br][br]
[br]
[br]
[br]
[br]
[/p]
[p]------------------------------------------------[br]关于这个组件还有其他的用法,列举如下:[br]webbrowser.execwb(1,1) 打开[br]web.execwb(2,1) 关闭现在所有的ie窗口,并打开一个新窗口[br]web.execwb(4,1) 保存网页[br]web.execwb(6,1) 打印[br]web.execwb(7,1) 打印预览[br]web.execwb(8,1) 打印页面设置[br]web.execwb(10,1) 查看页面属性[br]web.execwb(15,1) 好像是撤销,有待确认[br]web.execwb(17,1) 全选[br]web.execwb(22,1) 刷新[br]web.execwb(45,1) 关闭窗体无提示[/p]
[p]2、分页打印[br][br][br][br][br][br]<%while not rs.eof%>[br]
<%=rs(0)%>
[br]<%rs.movenext%>[br]<%wend%>[br][br][/p]
[p]3、asp页面打印时如何去掉页面底部的路径和顶端的页码编号[br](1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。[br](2)[br][br]
new document [br]
[br]
[br]<script language="vbscript">[br]dim hkey_root,hkey_path,hkey_key[br]hkey_root="hkey_current_user"[br]hkey_path="softwaremicrosoftinternet explorerpagesetup"[br]'//设置网页打印的页眉页脚为空[br]function pagesetup_null()[br]on error resume next[br]set regwsh = createobject("wscript.shell")[br]hkey_key="header" [br]regwsh.regwrite hkey_root+hkey_path+hkey_key,""[br]hkey_key="footer"[br]regwsh.regwrite hkey_root+hkey_path+hkey_key,""[br]end function[br]'//设置网页打印的页眉页脚为默认值[br]function pagesetup_default()[br]on error resume next[br]set regwsh = createobject("wscript.shell")[br]hkey_key="header" [br]regwsh.regwrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&p"[br]hkey_key="footer"[br]regwsh.regwrite hkey_root+hkey_path+hkey_key,"&u&b&d"[br]end function[br]</script>[br][/p]
[p][br]
[br]
[br]
[br]
[br]
[br]
[br]
[/p]
[p]
[br][br][br]4、浮动帧打印[br]<script language=javascript>[br]function button1_onclick() {[br]var odoc=window.iframe1.document;[br]var r=odoc.body.createtextrange();[br]var stxt=r.htmltext;[br]alert(stxt)[br]var pwin=window.open("","print");[br]pwin.document.write(stxt);[br]pwin.print();[br]}[br]</script>[br]4、用filesystem组件实现web应用中的本地特定打印[br]<script language=vbscript> [br]function print_onclick //打印函数 [br]dim label [br]label=document.printinfo.label.value //获得html页面的数据 [br]set objfs=createobject("scripting.filesystemobject") //创建filesystem组件对象的实例 [br]set objprinter=objfs.createtextfile ("lpt1:",true) //建立与打印机的连接 [br]objprinter.writeline("__________________________________") //输出打印的内容 [br]objprinter.writeline("| |") [br]objprinter.writeline("| 您打印的数据是:"&label& " |”) [br]objprinter.writeline("| |") [br]objprinter.writeline("|_________________________________|") [br]objprinter.close //断开与打印机的连接 [br]set objprinter=nothing [br]set objfs=nothing // 关闭filesystem组件对象 [br]end function [br]</script> [br]服务器端脚本: [br]<%……… [br]set conn=server.createobject ("adodb.connection") [br]conn.open "dsn=name;uid=xxxx;pwd=xxxx;" [br]set rs=server.createobject("adodb.recordset") [br]rs.open(“select ……”),conn,1,1 [br]……….%> //与数据库进行交互 [br]html页面编码: [br] [br]……… [br]