日期:2014-05-18  浏览次数:20692 次

打印功能是如何实现的
在JSP页面中的打印功能如在一个页面上点击打印按钮打印当前页面,或者是点打印按钮后到另一个页面进行预览确认后打印,这个功能是如何实现的.

------解决方案--------------------
onclick=self.print();
------解决方案--------------------
用javascript,JSP中加个按钮<input type="button" onclick="window.print()">即可。
------解决方案--------------------
<input type="button" value="打印" title="打印本页" onClick="window.print()">
<INPUT type="button" value="页面设置" title="设置本页面的列印格式" id=button1 name="setprint" onclick="setPrint();">

<SCRIPT LANGUAGE=javascript>
<!--
function setPrint(){
WB.ExecWB(8,1);
}
//-->
</SCRIPT>
------解决方案--------------------
<span id="printpart">
<script>
function printPreview()
{
WB.ExecWB(7,1);
}
</script>
<input type="button" id="btPrint" onclick="printPreview()" value="印刷" class="button" style="display:none;" />
</span>
------解决方案--------------------
给你一个我收藏许久的源码:js实现的打印,支持翻页:
http://blog.csdn.net/lcllcl987/archive/2005/11/25/536862.aspx
------解决方案--------------------
<script type="text/javascript">
function SubPrint()
{
var obj=document.getElementById('PrintContent')
var code=obj.innerHTML
newwin=window.open('','','') 
newwin.opener = null
newwin.document.write(code)
//newwin.document.write(code1)
newwin.document.write("<script>print();opener=null;</scr"+"ipt>");
newwin.document.close()
}
</script>
<body>
<table id="PeintContent">
<tr>
<td>要打印的内容……</td>
</tr>
</table>
</body>
------解决方案--------------------
每次看到java打印的东西怎么没有自己满意的东西
------解决方案--------------------
我来帮你解决吧,解决了给分呀
1.用ie的打印

onclick="javascript:self.parent.mainFrame.document.execCommand('print',true,null)" 
2.js打印
用Object实现打印
添加对象<object ID='WebBrowser1' WIDTH="0" HEIGHT="0" CLASSID='CLSID:8856F961-340A-11D0-A96B-00C04FD705A2'></object> 
添加如下JS函数:
<script type="text/javascript">
function print()
{
document.getElementById('WebBrowser1').ExecWB(6,1);
}
</script>
3.用ScriptX的打印控件
把smsx.cab放在ScriptX目录下
<object id="factory" viewastext style="display:none" viewastext
classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814"
codebase="ScriptX/smsx.cab#Version=6,3,435,20">
</object>
<script defer>
function window.onload() {
//factory.printing.paperSize = "A3"
factory.printing.header = ""
factory.printing.footer = ""
factory.printing.portrait = false
idPrint1.disabled = false; // enable UI button
idPrint2.disabled = false;
idPrint3.disabled = false;
idPrint4.disabled = false;
factory.printing.leftMargin = 0
factory.printing.topMargin = 5
factory.printing.rightMargin = 5
factory.printing.bottomMargin = 5