大家好:
工具:mysql + JSP + Jaspersoft ireport5.5.0
想問要怎麼中文字轉成直式書寫樣式
還有要如何傳參數,我在JSP頁面上選擇我要印的東西
確定後他幫我轉PDF,這樣該如何做?
<%@page import="net.sf.jasperreports.engine.*" %>
<%@page import="net.sf.jasperreports.engine.JasperRunManager"%>
<%@page import="java.sql.DriverManager"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="java.io.File"%>
<%@ page import="java.sql.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","1234");
File reportFile = new File(application.getRealPath("/report/report2.jasper"));//your report_name.jasper file
Map parameters = new HashMap();
byte[] bytes = JasperRunManager.runReportToPdf(reportFile.getPath(), parameters, conn);
response.setContentType("application/pdf");
response.setContentLength(bytes.length);
ServletOutputStream outStream = response.getOutputStream();
outStream.write(bytes, 0, bytes.length);
outStream.flush();
outStream.close();
%>
請高手幫忙
謝謝