Jump to content

PDF pages truncated to length of last page


mbarnard

Recommended Posts

I have a report which uses subreports and Break elements between them so that each subreport will show up on a separate Excel tab, and this works fine.

The problem comes when the report is exported to PDF.  In this case the report will have one PDF page for each tab, and the length of the last page seems to be determining the length of all the pages.  If the last page has the most data, everything is fine, but if the last page is short, all the other pages are truncated, even in the middle of detail rows.

Is this just the way the PDF exporter works?  Can PDF pages be different lengths?  Can we tell the exporter to use the longest page as the length for all pages?

 

Link to comment
Share on other sites

  • Replies 6
  • Created
  • Last Reply

Top Posters In This Topic

I assume you set isIgnorePagination for the report.

That can have adverse effects if you also want PDF exporting.  An alternative solution is to use the standard pagination attributes of the report, and to achieve the XLS tabs by setting the net.sf.jasperreports.export.xls.break.before.row/net.sf.jasperreports.export.xls.break.after.row properties (see here) on particular elements.

You can also log a bug to better handle the PDF export in the original scenario.

Regards,

Lucian

Link to comment
Share on other sites

Thanks for your reply Lucian.

I have a simple test report with three subreports that should generate three Excel tabs (using the net.sf.jasperreports.export.xls.one.page.per.sheet property) which I've been using for testing.

If I set Ignore Pagination to true in the master report and the subreports, then if I use Break elements in the master report I get 3 tabs in Excel, and 3 pages in the PDF.  If I use the break.after.row property on the last element of each subreport, then I get 3 tabs in the Excel but only 1 page in the PDF, because break.after.row only applies to the Excel exporter.

If I set Ignore Pagination to false in the master report and the subreports, then if I use either Break elements or the break.after.row property, I get many Excel tabs (one for each page due to normal pagination, plus empty tabs due to the Break elements or the break.after.row properties), but the PDF has normal pagination.  This is just what I'd expect, but I want just one Excel tab for each subreport, but many pages in the PDF.

The problem is that Excel tabs (worksheets) are coupled to pages, even though they are logically different things (I think!)

It would be much better if we could fill the report with normal pagination, and then have a property like xls.new.sheet.after.row to control tabs independently in the Excel exporter.  I'll look into logging this as a possible enhancement in the JR tracker.

 

 

Link to comment
Share on other sites

Set the net.sf.jasperreports.export.xls.one.page.per.sheet to false to avoid Excel sheets being created for each page in the generated report, and remove the break elements.  That way you'll only have Excel sheets created by break.after.row hints.

Regards,

Lucian

Link to comment
Share on other sites

  • 3 weeks later...

Thanks Lucian,

This works, mostly.  It's a little confusing.  Sometimes "break" means page break, and sometimes it means tab break...  It would be good if property names would distiinguish.

The "break.after.row" property doesn't work when applied to the subreport element itself.  I had to put it on a dummy textfield in a dummy band between my two subreport elements.  If I put it on a textfield element below the subreport element in the same band, it caused the break to occur before the subreport for some reason.

A bigger problem is that the "break.after.row" property prevents tab names from working when set using the net.sf.jasperreports.export.xls.sheet.names property, set at the report level.  I've tried one property followed by a list of tab names (Detail/Summary/Communities), as well as individual properties (...sheet.names.1, ...sheet.names.2, etc).  Instead of the three tab names "Detail", :"Summary", and "Communities" I get "Detail", "Detail 2" and "Detail 3".  Tab names do work when using page breaks to get tab breaks.

We are currently using JasperReports 3.5; perhaps this was fixed in a later version.

 

 

 

 

Link to comment
Share on other sites

  • 3 weeks later...
  • 6 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...