Setting page format

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:)

dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

14 Answers:

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

augarte's picture
6517
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 1 week ago
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?
dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

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.

augarte's picture
6517
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 1 week ago

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 output

JasperPrint 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

 

dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

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.html

Another 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.

augarte's picture
6517
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 1 week ago
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
dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago
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?
dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

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.

augarte's picture
6517
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 1 week ago

here is the ,jasper file. i hope you will find anything out. i really have no idea what can be wrong. 

dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

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
sanbez's picture
7132
Joined: Jan 11 2011 - 2:06am
Last seen: 2 years 11 months ago

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 0

Maybe 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
augarte's picture
6517
Joined: Jan 27 2010 - 7:20am
Last seen: 3 years 1 week ago

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

shertage's picture
22224
Joined: Sep 26 2006 - 8:06pm
Last seen: 2 months 3 weeks ago

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.4

my generated report  has definetly one page. adobe reader displays 1/1 in page number box



Post Edited by dvoryadkin1989 at 03/20/2012 15:42



Post Edited by dvoryadkin1989 at 03/21/2012 09:26
dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago

sanbez
Wrote:
 


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 luck



Post Edited by dvoryadkin1989 at 03/21/2012 09:37
dvoryadkin1989's picture
Joined: Mar 13 2012 - 12:51am
Last seen: 11 years 6 months ago
Feedback