dvoryadkin1989 Posted March 20, 2012 Share Posted March 20, 2012 I want my report pages to have A4 format. to do this i used 'report->Page Format...' in iReport. In PDF preview everything seems to be ok. But when i use the .jasper file to generate report from my application it has only one long page instead of a couple of standart pages. What is wrong with it? how can i tell jasper to generate multi-page report?Thanks for your replies and sorry for my English:) Link to comment Share on other sites More sharing options...
augarte Posted March 20, 2012 Share Posted March 20, 2012 Hi, In your report properties, check how is "Ignore Pagination" option. If you want to create the report in different pages this option should be unchecked.Hope this helps.Regards Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 I've already checked this out. It is unchecked. In iReport preview everything works fine. I've afraid that information about page format somehow doesn't get into .jrxml and .jarsper files and used only by iReport. Is it possible? if it is then how to specify that in jrxml? Link to comment Share on other sites More sharing options...
augarte Posted March 20, 2012 Share Posted March 20, 2012 The only difference is that when you check this option it adds the following attribute in the jrxml file: isIgnorePagination="true"Are you sure the .jasper file is the one created after unchecking this option? How do you generate the report in your application? Which output are you using? This information could be usefull to find out a solution. Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 This option is unchecked and jrxml doesn't contain isIgnorePagination attribute.I tried to generate report in two different ways:1. compiling jrxml via ireport and using jasper file<code>InputStream is = getClass().getResourceAsStream("../report.jasper");report = (JasperReport)JRLoader.loadObject(is);</code>2. compile jrxml myself in java application<code>InputStream is = this.getClass().getResourceAsStream("../report.jrxml");report = JasperCompileManager.compileReport(is);</code>After that i'm generating report<code>OutputStream out = response.getOutputStream(); // standart servlet outputJasperPrint reportOut = JasperFillManager.fillReport(report, params, dataset);JRExporter exporter = new JRPdfExporter();exporter.setParameter(JRExporterParameter.JASPER_PRINT, reportOut);exporter.setParameter(JRExporterParameter.OUTPUT_STREAM, out);exporter.exportReport();</code>In both situations result is equal. I'm pretty sure that i'm using the same jrxml and jasper in iReport and in java application Link to comment Share on other sites More sharing options...
augarte Posted March 20, 2012 Share Posted March 20, 2012 But where/how do you visualize this report? If I see the code I can figure out that it is in a web application. I have never used it but maybe what you need is to use JRHtmlExporter instead of JRPdfExporter: http://jasperreports.sourceforge.net/api/net/sf/jasperreports/engine/export/JRHtmlExporter.htmlAnother test you can do is to export your report to a pdf file and check if it is ok openning with Acrobat Reader or other software to read pdf files.JRPdfExporter PdfExporter = new JRPdfExporter ();InputStream is = getClass().getResourceAsStream("../report.jasper");report = (JasperReport)JRLoader.loadObject(is);PdfExporter.setParameter (JRExporterParameter.JASPER_PRINT,report);PdfExporter.setParameter (JRExporterParameter.OUTPUT_FILE_NAME, "Report.pdf");PdfExporter.exportReport (); This way you can know if the problem is with jasper or you just have a problem visualizing the report from your application.Hope this helps.Regards. Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 I do this:response.setHeader("Content-Disposition", "attachment; filename=report.pdf"); after response is sent to client browser offers to open file in Acrobat Reader. So it doesn't really differ from what you've suggested. Everything is fine except pagination.I need response as a pdf file. not as html odcument Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 I cannot find any information about how pages should look like in jrxml file. May be this is the problem? is it possible that 'right click on report -> Page Format...' is only for viewing through iReport and have nothing to do with real exporting? if so i need to specify something in the jrxml file or something. what do you think? Link to comment Share on other sites More sharing options...
augarte Posted March 20, 2012 Share Posted March 20, 2012 I'm sorry but I can't figure out what can be happening. Maybe if you post the jrxml file I can check it but I'm afraid I won't be able to reproduce it cause I guess you execute it with a database connection. Another option could be to attach the .jasper file. You can check it with the JasperViewer to see if it is paginated or not. If you attach it I'll have a look to it and try to help. Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 here is the ,jasper file. i hope you will find anything out. i really have no idea what can be wrong. Link to comment Share on other sites More sharing options...
sanbez Posted March 20, 2012 Share Posted March 20, 2012 Check you java-code on presence parameter IS_IGNORE_PAGINATION (or set it on false):params.put("IS_IGNORE_PAGINATION", false);JasperPrint reportOut = JasperFillManager.fillReport(report, params, dataset);and check Page Height in reportProperties in iReport. May be it is so big?Post Edited by sanbez at 03/20/2012 14:53 Link to comment Share on other sites More sharing options...
augarte Posted March 20, 2012 Share Posted March 20, 2012 Hi,I have tried viewing the .jasper file you attached with the JasperViewer and exporting it to pdf and in both cases I get the same error:net.sf.jasperreports.engine.JRRuntimeException: Unknown hyperlink target 0Maybe you have some problem with the jasper file... are you using any hyperlink? Try removing it and check if you still have the same problem. * I edit the post because maybe the problem is mine because the jasper version I'm using is older than yours... which version are you using?Post Edited by augarte at 03/20/2012 14:55 Link to comment Share on other sites More sharing options...
szaharia Posted March 20, 2012 Share Posted March 20, 2012 Hi,I also checked the .jasper file. It appears as paginated, undoubtfully.Maybe the problem comes from the viewer itself. To see if this is the case, try to open another PDF file with the same PDF viewer on that machine, and see if it's displayed also as a continuum page. If so, then settings in the PDF viewer should be changed, in order to show a gap between pages.For instance, in Adobe Reader ensure that View --> Page Display --> Show Gaps Between Pages is checked.Hope this helps,sanda Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 20, 2012 Author Share Posted March 20, 2012 I'm using adobe reader and it displays pages correctly in every document except mine. 'Show Gaps Between Pages' is checked. moreover when previewing report, iReport opens it in the same adobe reader and it is perfectly fine. misterious.... p.s. my iReport version is 3.7.4my generated report has definetly one page. adobe reader displays 1/1 in page number boxPost Edited by dvoryadkin1989 at 03/20/2012 15:42Post Edited by dvoryadkin1989 at 03/21/2012 09:26 Link to comment Share on other sites More sharing options...
dvoryadkin1989 Posted March 21, 2012 Author Share Posted March 21, 2012 sanbezWrote: params.put("IS_IGNORE_PAGINATION", false); JasperPrint reportOut = JasperFillManager.fillReport(report, params, dataset); That worked! It appears that this parameter is not inherited from iReport. Thanks for helping everyone and good luckPost Edited by dvoryadkin1989 at 03/21/2012 09:37 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