ScriptX HTML打印控件(java)
来源:互联网 发布:上海英方软件福利待遇 编辑:程序博客网 时间:2024/06/11 13:05
ScriptX HTML打印控件
dullhunter @ 2007-07-03 09:41 | JAVA
ScriptX HTML打印控件 配合ireport报表- <%@ page language="java" contentType="text/html;charset=GBK"%>
- <%@ page import="net.sf.jasperreports.engine.JasperFillManager"%>
- <%@ page import="com.frameworkset.common.poolman.PreparedDBUtil"%>
- <%@ page import="com.frameworkset.common.poolman.util.SQLResult"%>
- <%@ page import="net.sf.jasperreports.engine.JasperPrint"%>
- <%@ page import="net.sf.jasperreports.engine.JRExporter"%>
- <%@ page import="net.sf.jasperreports.engine.export.JRHtmlExporter"%>
- <%@ page import="net.sf.jasperreports.engine.export.JRHtmlExporterParameter"%>
- <%@ page import="net.sf.jasperreports.engine.JRExporterParameter"%>
- <%@ page import="java.util.*"%>
- <%@ page import="java.sql.*"%>
- <%@ page import="java.net.*"%>
- <%@ page import="java.io.*"%>
- <%@ page import="com.chinacreator.shoa.common.OAUtil"%>
- <script defer="defer">
- function window.onload() {
- // -- advanced features
- factory.printing.SetMarginMeasure(2); // measure margins in inches
- //factory.printing.printer = "HP DeskJet 870C";
- factory.printing.paperSize = "A4";
- factory.printing.paperSource = "Manual feed";
- factory.printing.collate = true;
- factory.printing.copies = 1;
- factory.printing.SetPageRange(false, 1, 1); // need pages from 1 to 3
- // -- basic features
- factory.printing.header = "This is MeadCo";
- factory.printing.font = "宋体";
- factory.printing.footer = "Advanced Printing by ScriptX";
- factory.printing.portrait = false;
- factory.printing.leftMargin = 1.0;
- factory.printing.topMargin = 1.0;
- factory.printing.rightMargin = 1.0;
- factory.printing.bottomMargin = 1.0;
- }
- </script>
- <script language="javascript">
- function printTure() //打印函数
- {
- document.all("dayinDiv").style.display="none";//隐藏按钮
- factory.printing.Print(true); //调用控件打印
- document.all("dayinDiv").style.display="";//显示
- }
- function printTurePre() //打印预览
- {
- document.all("dayinDiv").style.display="none";//隐藏按钮
- factory.printing.Preview(); //调用控件预览
- document.all("dayinDiv").style.display="";//显示
- }
- function printTureSet() //设置函数
- {
- document.all("dayinDiv").style.display="none";//隐藏按钮
- factory.printing.PageSetup(); //调用控件设置
- document.all("dayinDiv").style.display="";//显示
- }
- </script>
- <div id="dayinDiv" style="display: block;" name="dayinDiv">
- <input value="打印本页" class="buttonActive" onclick="printTure()" type="button">
- <input value="页面设置" class="buttonActive" onclick="printTureSet()" type="button">
- <input value="打印预览" class="buttonActive" onclick="printTurePre()" type="button">
- </div>
- <% String id = request.getParameter("id");
- String type = request.getParameter("type");
- String filename = "";
- String tablename = "arch_dispatch";//发文
- if("1".equals(type)){
- filename = "fawen.jasper";//发文
- } else if("2".equals(type)){
- filename = "audit.jasper";//模块上线
- tablename = "td_workflow_use_audit";
- } else{//收文
- filename = "shouwen.jasper";
- tablename = "arch_receive";
- }
- URL url = OAUtil.class.getResource("OAUtil.class");
- String pkgName = OAUtil.class.getPackage().getName();
- pkgName = pkgName.replace('.', '/');
- String filePath = url.getFile();
- String webinfoPath = filePath.substring(1, filePath.indexOf("WEB-INF/classes/" + pkgName));
- //out.println(webinfoPath);
- try {
- JasperPrint jp = null;
- java.util.Map map = new java.util.HashMap();
- java.sql.Connection con = null;
- PreparedDBUtil pd = new PreparedDBUtil();
- con = pd.getConection();
- map.put("SQLSTR", "select * from "+tablename+" where id ='"+id+"'");
- if("0".equals(type)){
- String tmpsql = "select id, createman,trans_flag,createdept,receive_no_postfix,receive_no1,pishinameid, pishiname,yuewennameid,yuewenname,yuebannameid,yuebanname,deptdealmanid,deptdealman, arch_co,arch_no,receive_no,secrecy_grade,title,to_char(createdate,'yyyy') ||' 年 '||to_char(createdate,'mm')||' 月 '||to_char(createdate,'dd')||' 日 ' as createdate,to_char(receivedate,'yyyy')||' 年 '||to_char (receivedate,'mm')||' 月 '||to_char(receivedate,'dd')||' 日 ' as receivedate,workmemo,auditmemo,readmemo,deptmemo,fd_num,yuebanren from arch_receive where id = '"+id+"'";
- map.put("SQLSTR", tmpsql);
- } else if("1".equals(type)){//发文
- String subsqlstr = "select t.oldfilename,t.createman from td_afx_file t where t.businessid='"+id+"'";
- map.put("SUBSQLSTR", subsqlstr);
- map.put("SUBREPORT_DIR",webinfoPath);
- }else if("2".equals(type)){
- String tmpsql = "select id, code,createman,to_char(createdate,'yyyy')||' 年 '||to_char(createdate, 'mm')||' 月 '||to_char(createdate,'dd')||' 日 ' as createdate,dept, to_char(usedate,'yyyy')||' 年 '||to_char(usedate,'mm')||' 月 '||to_char (usedate,'dd')||' 日 ' as usedate,title,managerman,deptmemo,managermemo, checkresult,deptresult,managerresult,deptman,deptdate,managerdate,usememo,trans_flag,leader,leaderid from td_workflow_use_audit where id = '"+id+"'";
- map.put("SQLSTR", tmpsql);
- System.out.println(tmpsql);
- }
- jp = JasperFillManager.fillReport(webinfoPath+filename, map, con);
- StringBuffer sout = new StringBuffer();
- try {
- JRExporter exporter = new JRHtmlExporter();
- exporter.setParameter(JRExporterParameter.JASPER_PRINT, jp);
- exporter.setParameter(JRExporterParameter.OUTPUT_STRING_BUFFER,
- sout);
- exporter.setParameter(JRHtmlExporterParameter.IMAGES_URI, "report_image/");
- exporter.setParameter(JRHtmlExporterParameter.
- IS_REMOVE_EMPTY_SPACE_BETWEEN_ROWS,
- Boolean.TRUE); // 删除记录最下面的空行
- exporter.setParameter(JRHtmlExporterParameter.HTML_HEADER, "");
- exporter.setParameter(JRHtmlExporterParameter.
- BETWEEN_PAGES_HTML, "");
- exporter.setParameter(JRHtmlExporterParameter.HTML_FOOTER, "");
- exporter.setParameter(JRHtmlExporterParameter.
- IS_USING_IMAGES_TO_ALIGN,
- Boolean.valueOf(true));
- exporter.exportReport();
- %>
- <!--startprint-->
- <div id="jasper" style="display: block;" name="dayinDiv">
- <%
- out.println(sout.toString());
- %>
- </div>
- <!--endprint-->
- <object id="factory" viewastext="" style="display: none;" classid="clsid:1663ed61-23eb-11d2-b92f-008048fdd814" codebase="./ScriptX/smsx.cab#Version=6,2,433,70" height="0" width="0">
- </object>
- <%
- } catch (Exception e) {
- e.printStackTrace();
- sout.append("生成报表数据错误!");
- }
- } catch (Exception e1) {
- e1.printStackTrace();
- //System.out.println("final exception");
- }
- %>
- ScriptX HTML打印控件(java)
- scriptX打印控件
- ScriptX控件 web打印参数
- ScriptX打印控件的使用
- ScriptX,smsx打印控件安装的解决办法
- web打印ScriptX控件smsx.cab使用方法
- WEB打印ScriptX控件smsx.cab使用方法
- 使用ScriptX控件进行Web打印总结
- 使用ScriptX控件进行Web打印 asp打印(源码)
- ScriptX,smsx打印控件安装的终极解决办法
- A4纸规格的WEB打印 ScriptX 控件
- 使用MeadCo's ScriptX控件做WEB打印
- ScriptX 页面打印
- ScriptX打印问题
- WEB打印设置解决方案二(利用ScriptX.cab控件改变IE打印设置)
- WEB打印设置 方案二(利用ScriptX.cab控件改变IE打印设置)
- WEB打印设置解决方案二(利用ScriptX.cab控件改变IE打印设置)
- ScriptX控件如何在不跳转页面的情况下将要打印的内容打印出来
- oracle数据字典
- 电脑故障代码汇总(转载)
- Oracle函数大全
- Microsoft.Net中数字签名技术
- document对象
- ScriptX HTML打印控件(java)
- tracert 原理
- 确定一个Excel表格的最大行数和最大列数
- “中国股票第一博”带头大哥777涉嫌非法经营被调查
- Visual C++编程实现摄像头视频捕捉
- 一个用爬楼来讲人生的故事
- 博客公告
- MIME 介绍
- 日开户数跌至6万 第二次散户时代彻底终结