mackensen Posted September 17, 2009 Share Posted September 17, 2009 Hello,I have a web app with Struts 1.2.9 and JasperReport 3.5.2.The problem is that when I create an Action to generate a pdf I get an empty pdf. I created the .jrxml file with iReport 3.5.2 and I put on it just a static text.I also tried to export to XML. I get the XML tree but there's only the name of the report so I presume that the path to the report is ok, I mean, the application gets the right report file.Below is the code:Thanx,Mack Code:public ActionForward printPdf(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { ServletOutputStream out=response.getOutputStream(); //i also tried with OutputStream response.setContentType( "application/pdf" ); JasperDesign jasperDesign=null; JasperReport jasperReport=null; String reportFile=""; reportFile=this.getServlet().getServletConfig().getServletContext().getRealPath("/reports/Print_indComm.jrxml"); Map parameters_header=null; parameters_header=this.getParametersHeaderPdf(idComm); //this method and parameter are defined try { jasperDesign = JRXmlLoader.load(reportFile); jasperReport = JasperCompileManager.compileReport(jasperDesign); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters_header); JasperExportManager.exportReportToPdfStream(jasperPrint, out); out.flush(); out.close(); } catch (Exception ex) { String connectMsg = "Could not create the report " + ex.toString() + " " + ex.getLocalizedMessage(); response.setContentType("text/html;charset=UTF-8"); PrintWriter out1 = response.getWriter(); out1.println(connectMsg); out1.close(); } return mapping.getInputForward(); } Link to comment Share on other sites More sharing options...
Teodor Danciu Posted September 18, 2009 Share Posted September 18, 2009 Hi, When you fill your report, you don't provide any data source or DB connection, do you? In that case, you should set the "whenNoDataType" report property to "AllSectionsNoDetail" or supply an instance of the JREmptyDataSource. I hope this helps. Teodor[/code] Link to comment Share on other sites More sharing options...
mackensen Posted September 18, 2009 Author Share Posted September 18, 2009 Yes, there's no datasource.It works now !!! Thanx a lot !Mack Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now