views:

23

answers:

0

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?