Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jasper Reports: correct Table of Contents possible?

I implemented a TOC into my report as described in the official Jasper Report examples.

It works well within the limitations mentioned in the example:

This operation has apparently only one inconvenience. The final document does not reflect the modification in the order of pages. You can see that in our sample, the table of contents does not display a page number on the footer and that the page #1 comes after the table of contents.

To work around this limitation I only need one thing: A variable (or whatever) which tells me how many pages the TOC has.

When assuming a one-page TOC I can just add 1 to current and total page numbers in the Page Footer of my document. Then my 20 page PDF would have the following pages:

  • TOC (without page footer)
  • 2/20
  • 3/20
  • ...
  • 19/20
  • 20/20

Additionally I would need to add one to each Heading in the Heading subreport to correct my page numbers. But as my TOC can be longer then one page this is not an optimal solution.

Is there any way to do this?

like image 831
arturh Avatar asked Oct 29 '10 11:10

arturh


1 Answers

I know this is an very, very old topic. But I stumbled on this topic while searching for something else and I just have to react on this, because it's an frequently asked feature and since version 6.0 implemented in a very easy way on Jasper Reports!

  1. Add a new 'Jasper Report
  2. In 'Categories' select 'Report Books' and select one you like
  3. (next, next) And it then gives you options like 'Create table of contents'

What they basically did was create a new sort of jrxml, which is the Workbook, which can contain cover, backcover, TOC (with more inteliggence then before) and content in the middle (which are other jrxml's)

Hope someone finds this helpfull

like image 145
Gert Oussoren Avatar answered Nov 20 '22 20:11

Gert Oussoren