一、调用WebBrowser进行打印
定义一个打印页面,在其他需要打印的页面调用此页面即可。
定义内容如下:
<%@ page language="java" pageEncoding="utf-8"%>
<script type="text/javascript">
var printSetup = function(){
// 打印页面设置
wb.execwb(8,1);
}
var printPreView = function(){
// 打印页面预览
wb.execwb(7,1);
}
var printIt = function(){
if (confirm('确定打印吗?')) {
window.print();//
}
}
var windowClose = function(){
window.opener=null;
window.open('','_self');
window.close();
};
</script>
<style type="text/css">
.Noprint{display : none }
</style>
<center class="Noprint">
<p class="Noprint">
<OBJECT id="wb" height="0" width="0" classid="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2" name="wb"></OBJECT>
<input type=button value="打印" onclick="printIt()">
<input type=button value="预览" onclick="printPreView()">
<input type=button value="设置" onclick="printSetup()">
<input type=button value="关闭" onclick="windowClose()">
</p>
</center>
其他页面调用方式极为简单:
<%@includefile="print.jsp"%>