asp打印问题

我做了一个word摸板,然后从数据库中调用数据添入摸板中并实现打印,需要是用A4纸横向打印,要在页面中实现打印功能

请教?希望提供代码!谢谢

谁帮忙成功解决了,我将再在论坛里发 给分帖给分
---------------------------------------------------------------

web打印的大全:

1、控制"纵打"、 横打”和“页面的边距。
(1)

 1<script defer="">   
 2function SetPrintSettings() {   
 3// -- advanced features   
 4factory.printing.SetMarginMeasure(2) // measure margins in inches   
 5factory.SetPageRange(false, 1, 3) // need pages from 1 to 3   
 6factory.printing.printer = "HP DeskJet 870C"   
 7factory.printing.copies = 2   
 8factory.printing.collate = true   
 9factory.printing.paperSize = "A4"   
10factory.printing.paperSource = "Manual feed"   
11  
12// -- basic features   
13factory.printing.header = "This is MeadCo"   
14factory.printing.footer = "Advanced Printing by ScriptX"   
15factory.printing.portrait = false   
16factory.printing.leftMargin = 1.0   
17factory.printing.topMargin = 1.0   
18factory.printing.rightMargin = 1.0   
19factory.printing.bottomMargin = 1.0   
20}   
21</script>

(2)

 1<script language="javascript">   
 2function printsetup(){   
 3// 打印页面设置   
 4wb.execwb(8,1);   
 5}   
 6function printpreview(){   
 7// 打印页面预览   
 8  
 9wb.execwb(7,1);   
10  
11  
12}   
13  
14function printit()   
15{   
16if (confirm('确定打印吗?')) {   
17wb.execwb(6,6)   
18}   
19}   
20</script>
 1<body>
 2<object classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" height="0" id="wb" name="wb" width="0"></object>
 3<input name="button_print" onclick="javascript:printit()" type="button" value="打印"/>
 4<input name="button_setup" onclick="javascript:printsetup();" type="button" value="打印页面设置"/>
 5<input name="button_show" onclick="javascript:printpreview();" type="button" value="打印预览"/>
 6<input name="button_fh" onclick="javascript:window.close();" type="button" value="关闭"/>   
 7  
 8\------------------------------------------------   
 9关于这个组件还有其他的用法,列举如下:   
10WebBrowser.ExecWB(1,1) 打开   
11Web.ExecWB(2,1) 关闭现在所有的IE窗口,并打开一个新窗口   
12Web.ExecWB(4,1) 保存网页   
13Web.ExecWB(6,1) 打印   
14Web.ExecWB(7,1) 打印预览   
15Web.ExecWB(8,1) 打印页面设置   
16Web.ExecWB(10,1) 查看页面属性   
17Web.ExecWB(15,1) 好像是撤销,有待确认   
18Web.ExecWB(17,1) 全选   
19Web.ExecWB(22,1) 刷新   
20Web.ExecWB(45,1) 关闭窗体无提示   
21  
222、分页打印   
23<html>
24<head>
25<style>   
26P {page-break-after: always}   
27</style>
28</head>
29<body>   

while not rs.eof

1<p>```
2=rs(0)
3```</p>   

rs.movenext

wend

 1</body>
 2</html>   
 3  
 43、ASP页面打印时如何去掉页面底部的路径和顶端的页码编号   
 5(1)ie的文件-〉页面设置-〉讲里面的页眉和页脚里面的东西都去掉,打印就不出来了。   
 6(2)<html>
 7<head>
 8<title> New Document </title>
 9<meta content="EditPlus" name="Generator"/>
10<meta content="YC" name="Author"/>
11<script language="VBScript">   
12dim hkey_root,hkey_path,hkey_key   
13hkey_root="HKEY_CURRENT_USER"   
14hkey_path="\Software\Microsoft\Internet Explorer\PageSetup"   
15'//设置网页打印的页眉页脚为空   
16function pagesetup_null()   
17on error resume next   
18Set RegWsh = CreateObject("WScript.Shell")   
19hkey_key="\header"   
20RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""   
21hkey_key="\footer"   
22RegWsh.RegWrite hkey_root+hkey_path+hkey_key,""   
23end function   
24'//设置网页打印的页眉页脚为默认值   
25function pagesetup_default()   
26on error resume next   
27Set RegWsh = CreateObject("WScript.Shell")   
28hkey_key="\header"   
29RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&w&b页码,&p/&P"   
30hkey_key="\footer"   
31RegWsh.RegWrite hkey_root+hkey_path+hkey_key,"&u&b&d"   
32end function   
33</script>
34</head>
35<body>
36<p align="center">
37<input onclick="pagesetup_null()" type="button" value="清空页码"/> <input onclick="pagesetup_default()" type="button" value="恢复页吗"/>
38</p>
39</body>
40</html>   
414、浮动帧打印   
42<script language="javascript">   
43function button1_onclick() {   
44var odoc=window.iframe1.document;   
45var r=odoc.body.createTextRange();   
46var stxt=r.htmlText;   
47alert(stxt)   
48var pwin=window.open("","print");   
49pwin.document.write(stxt);   
50pwin.print();   
51}   
52</script>   
534、用FileSystem组件实现WEB应用中的本地特定打印   
54<script language="VBScript">   
55function print_onclick //打印函数   
56dim label   
57label=document.printinfo.label.value //获得HTML页面的数据   
58set objfs=CreateObject("Scripting.FileSystemObject") //创建FileSystem组件对象的实例   
59set objprinter=objfs.CreateTextFile ("LPT1:",true) //建立与打印机的连接   
60objprinter.Writeline("__________________________________") //输出打印的内容   
61objprinter.Writeline(" ¦ ¦")   
62objprinter.Writeline(" ¦ 您打印的数据是:"&label& " ¦”)   
63objprinter.Writeline(" ¦ ¦")   
64objprinter.Writeline(" ¦_________________________________ ¦")   
65objprinter.close //断开与打印机的连接   
66set objprinter=nothing   
67set objfs=nothing // 关闭FileSystem组件对象   
68end function   
69</script>   
70服务器端脚本:   

………
set conn=server.CreateObject ("adodb.connection")
conn.Open "DSN=name;UID=XXXX;PWD=XXXX;"
set rs=server.CreateObject("adodb.recordset")
rs.Open(“select ……”),conn,1,1
……….

 1HTML页面编码:   
 2<html>   
 3………   
 4<form id="printinfo" name="printinfo">
 5<input id="print" name="print" type="button" value="打印&gt;&gt;"/> //调用打印函数   
 6<input =………="" ```="" id="text1" name="label" type="hidden" value="```"/> //保存服务器端传来的数据   
 7………   
 8</form></html>   
 9  
10  
11\---------------------------------------------------------------   
12  
13http://expert.csdn.net/Expert/topic/1940/1940823.xml?temp=.5007135</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus