Subreport: Total number of pages

1

Hi,

The most of the Reports of my application have a common page footer. Therefore, I'm trying to generate a subreport that contains this content to be embedded in all reports.
However, this common footer contains the pagination of the Report with the following format: Page X of Y where Y is the total number of pages of the Report.

I have defined this subreport passing the pagination as parameter from the master Report, but I have not been able to display the total number of pages.
I think that the problem is that when the total number of pages is evaluated in the master Report to be passed as parameter to the subreport, the master Report is not able to determine how many pages will have the report yet.

I have already read some posts about this problem and it seems that is not possible to solve it, but I would like to know if someone has found a solution

Thanks

Miguel Angel Marina

miguelangel.marina's picture
Joined: Dec 18 2013 - 12:48am
Last seen: 5 years 10 months ago

3 Answers:

0

Hi,

I have the same problem.

Regards

misterfoo47's picture
Joined: Dec 18 2013 - 6:02am
Last seen: 5 years 11 months ago
0

Hi,

As you would have noticed that in the template Page X of Y   - 'Page X of' has an evaluation time of NOW where as 'Y ' has an evaluation time of 'Report'. This trigers the time when they are evaluated, in your case you are passing this value as parameter in the subreport and that is placed in the Page Footer, this will pass the current page number instead of the total count. This happens because the page footeris encountered at the end of every single page which demands the value of the Total Page, but total is failed to be generated as its evaluation time is Report so it passes the current page number of the master report.

Now another thing is that if you want to use scriptlets to determine the total page number that is also not possible beacause when the scriptlet events are fired, the JasperPrint onject which is created at the runtime of the JRXML is not yet final, so we can still not get the total number of pages.

So as far as I know, we cannot obtain the total number of pages of the report and pass it to any other subreport or element for manipulation.

Though, a workaround in you case can be -
You can place the page number portion in the main report and keep the rest in the subreport.

 

Hope that helps.

 

Thanks,

Ankur

Ankur Gupta's picture
Joined: Jan 21 2013 - 10:36pm
Last seen: 2 months 1 week ago
0

Hi,

Thanks for your response.

Yes, I had already thought to place the page number portion in the main report, but I wanted to confirm that there does not exist a workaround to place all content in the subreport.

Thanks,

 

Miguel Angel Marina

 

 

miguelangel.marina's picture
Joined: Dec 18 2013 - 12:48am
Last seen: 5 years 10 months ago
Feedback
randomness