Jump to content
Changes to the Jaspersoft community edition download ×

cameron_1
Go to solution Solved by teodord,

Recommended Posts

So, I can't figure out why it's so difficult/annoying to use page numbers in iReport, surely there's an easier way?

The current method I'm employing is actually having 2 text fields! 1 is have $V{PAGE_NUMER} and is evaluated "Now", giving me the current page, then another with $V{PAGE_NUMER} evaluated at "Report", giving me to total number.

Of course having 2 text fields absolutely ruins the formatting! You end up with inconsistent spacing between the 2 text fields, when you've got a single digit you have a larger gap than a double digit! It's ridiculous, surely there's a better way???

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

Hi,

I solved this problem with "reparsing" the resulting JasperPrint-Object (so all elements at each page) and set my "Page #X# of #Y#" Placeholder with the corresponding values from final JasperPrint - works fine and fast (< 1sec) and solves the same layout problems that you also have.

Of course this works only with JasperReports API and also not with Groups that have their own PageNumbering (ResetPageNumber flag set) - but this is not needed for my case.

When I remember right someone posted also a pure variable (so no API coding needed) solution with a StackVariable that is calculated at each Page and a textfield that uses this StackVariable with evaluationtime = report .. but this was also quite tricky and not a "end user" solution where no JasperReports gurus just want to place some fields at report. (use search function for this forum)

hth

regards from rainy Germany

C-Box

 

Link to comment
Share on other sites

  • Solution

Hi,

 

Instead of using two text fields, one with evaluationTime=Now and the other with evaluationTime=Report, you could use only one text field with evaluationTime=Auto.

In order for this to work, you need to use in your expression two variables that have different resetType levels.

The build-in PAGE_NUMBER variable is good for the total number of pages. But for the current page number, you need a custom made variable, let's call it CRT_PAGE_NUMBER, which has calculation=Nothing and resetType=Page, which copies the value of the PAGE_NUMBER variable in its expression.

I hope this helps.
Teodor

 

Link to comment
Share on other sites

  • 3 years later...
  • 1 month 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...