Jump to content
We've recently updated our Privacy Statement, available here ×

Subreport: Total number of pages


miguelangel.marina

Recommended Posts

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

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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

Link to comment
Share on other sites

  • 10 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...