Jasper Reports: Is Correct Content Possible?

I have embedded TOC in my report as described in the Jasper Report.

It works well within the limitations mentioned in the example:

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

To get around this limitation I only need one: a variable (or something else) that tells me how many pages TOC has.

When accepting a single-page TOC, I can simply add 1 to the current and total page numbers in the footer of my document. Then my 20-page PDF will have the following pages:

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

In addition, I will need to add one for each heading in the Subheading Heading to correct page numbers. But since my TOC may be longer than one page, this is not an optimal solution.

Is there any way to do this?

+7
jasper-reports
source share
2 answers

I know this is a very, very old topic. But I came across this topic while searching for something else, and I just need to respond to it, because it is a frequently asked function and since version 6.0 it has been implemented very simply on Jasper Reports!

  • Add New Jasper Report
  • In the Categories section, select Reporting Books and choose the one you like.
  • (next, next) And then it gives you options like Create a table of contents

What they basically did was create a new kind of jrxml, which is a Workbook that can contain a cover, cover, TOC (with more intelligence than before) and content in the middle (these are other jrxml)

Hope someone finds this useful

+2
source share

I can’t see what example you had. But maybe you put the page number in a sub-report of the content. I will have a report with 4 sub-reports

  • auxiliary report on the main page
  • TOC sub-report
  • Sub-report on content with variable page number
  • Index sub-report

If this does not work, please share the link with your example.

0
source share

All Articles