[求助]有关页面数据打印问题,高手请进!

页面上的数据是一张(如凭证)的缩小,现在想放一个打印按钮,点击使表单中的数据打印在凭证中需要填数据的地方,也就是实现套打功能,请各位高手赐教!!!
---------------------------------------------------------------

这样很难控制的,你去找一个数据控件吧.

把控件存放控件里面,然后在打印.

如华表.还有一个叫什么的.你搜索一下帖子,

还有你把生成的数据存到excel,或word中,然后在打印.

这样就比较完美了呀.
---------------------------------------------------------------

这种打印也不是很难,就是一个定点的问题(VB里实现过)
有个缺陷,当你的凭证版本变了,它就得再改设置
我这里只有VB的
---------------------------------------------------------------

1<head>
2<title>打印确认</title>
3<style media="print">   
4.noprint { display: none }   
5</style>
6</head>
 1<body>
 2<object classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="http://www.meadroid.com/scriptx/ScriptX.cab#Version=5,60,0,360" id="factory" style="display:none" viewastext=""></object>
 3<script defer="">   
 4function window.onload() {   
 5//factory.printing.paperSize = "A3"   
 6factory.printing.header = ""   
 7factory.printing.footer = ""   
 8factory.printing.portrait = false   
 9idPrint1.disabled = false; // enable UI button   
10idPrint2.disabled = false;   
11idPrint3.disabled = false;   
12idPrint4.disabled = false;   
13factory.printing.leftMargin = 0.75   
14factory.printing.topMargin = 1.5   
15factory.printing.rightMargin = 0.75   
16factory.printing.bottomMargin = 1.5   
17}   
18</script>
19<div class="noprint">
20<input id="idPrint1" onclick="factory.printing.Print(false)" type="button" value="打印本页"/>
21<input id="idPrint2" onclick="factory.printing.PageSetup()" type="button" value="页面设置"/>
22<input id="idPrint3" onclick="factory.printing.Preview()" type="button" value="打印预览"/>
23<input id="idPrint4" onclick="window.close()" type="button" value="关闭窗口"/>
24</div>
25<table align="center" border="0" cellpadding="0" cellspacing="0" width="720">
26<tr>
27<td bgcolor="#0099ff">   
28这里是你要打印的内容,上面的按钮不会被打印出来
29   
30factory.printing.paperSize = "A3"   
31</td>
32</tr></table></body>

---------------------------------------------------------------

这些可能对你有用:

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<br/>
37<br/>
38<br/>
39<br/>
40<br/>
41<br/><p align="center">
42<input onclick="pagesetup_null()" type="button" value="清空页码"/> <input onclick="pagesetup_default()" type="button" value="恢复页吗"/><br/>
43</p>
44</body>
45</html>   
464、浮动帧打印   
47<script language="javascript">   
48function button1_onclick() {   
49var odoc=window.iframe1.document;   
50var r=odoc.body.createTextRange();   
51var stxt=r.htmlText;   
52alert(stxt)   
53var pwin=window.open("","print");   
54pwin.document.write(stxt);   
55pwin.print();   
56}   
57</script>   
584、用FileSystem组件实现WEB应用中的本地特定打印   
59<script language="VBScript">   
60function print_onclick //打印函数   
61dim label   
62label=document.printinfo.label.value //获得HTML页面的数据   
63set objfs=CreateObject("Scripting.FileSystemObject") //创建FileSystem组件对象的实例   
64set objprinter=objfs.CreateTextFile ("LPT1:",true) //建立与打印机的连接   
65objprinter.Writeline("__________________________________") //输出打印的内容   
66objprinter.Writeline(" ¦ ¦")   
67objprinter.Writeline(" ¦ 您打印的数据是:"&label& " ¦”)   
68objprinter.Writeline(" ¦ ¦")   
69objprinter.Writeline(" ¦_________________________________ ¦")   
70objprinter.close //断开与打印机的连接   
71set objprinter=nothing   
72set objfs=nothing // 关闭FileSystem组件对象   
73end function   
74</script>   
75服务器端脚本:   

………
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你的模板可以作成txt/excel/word,等等,我建议是excel,然后存放在你的web目录里,具体:   
13set objApp = CreateObject("Excel.Application")   
14set objApp1 = CreateObject("Excel.Application")   
15set objBook1 = objApp1.Workbooks.Add()   
16strPath="c:/webroot/doc/templete.xls" '模板路径   
17set objBook = objApp.Workbooks.Open(strPath)   
18  
19set objSheet = objBook.Worksheets(1)   
20if iSheetCounts &gt; 3 then 'Excel中1个Workbook默认有三个工作表   
21set objSheet1 = objBook1.Worksheets.Add()   
22else   
23set objSheet1 = objBook1.Worksheets(iSheetCounts)   
24iSheetCounts = iSheetCounts+1   
25end if   
26for x = 1 to 45   
27for y = 1 to 15   
28if</body>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus