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???
2 Answers:
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
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
Perfect, exactly what I was after!
This should be documented somewhere, for future reference!
I am getting a null value for the CRT_PAGE_NUMBER. Do you have idea how can this be fixed?
Getting the same null value for the CRT_PAGE_NUMBER. Is there something I am missing?