I have added the footer Page x of y to my report, but the PAGE_COUNT doesn't seem to work.
Maybe the problem occurs because I have many subreports?
I get:
Page 1 of 1
Page 2 of 0
Page 3 of 0
Page 4 of 0
Any ideas?
I found the solution.
http://jasperforge.org/tracker/index.php?func=detail&aid=2873&group_id=102&atid=612
But the book JasperReports for Java Developers (p 146) says that PAGE_COUNT is the total number of pages in the report. I guess the bug is in the book.
Actually It Is a BUG! And confirmed by developers.
See link: jasper community bug tracker link
PAGE_COUNT is not correctly calculated, when using property on BAND: "Split Prevent"
Summary: To have the page number and the page number in a TextField.
Step 1: Create a variable that indicates the number of the current page. Settings: * Name: CURRENT_PAGE_NUMBER
Variable class: Java.lang.Integer
Calculation: nothing
Reset Type: None
Increment type: Page
Variable Expression: $ V {CURRENT_PAGE_NUMBER} == null? $ V {PAGE_NUMBER}: $ V {PAGE_NUMBER} +1
Step 2: TextField Settings
Text Field Expression: "PAGE:" + $ V {CURRENT_PAGE_NUMBER} + "/" + $ V {PAGE_NUMBER}
Expression class: Java.lang.String
Evaluation Time: Auto
And that's all. No need to add anything to it to give you a result like: Page 1/3 | Page 2/3 | Page 3/3.
I haven't access to the jaspercommunity (to check the link shared), but I do a good workaround :D
Use 4 texts, like this:
txtStatic1(Page) txtField1($V{PAGE_NUMBER}) txtStatic2(of) txtField2($V{PAGE_NUMBER})
Where:
txtField1($V{PAGE_NUMBER}) -> AVAILABLE TIME = PAGE
txtField2($V{PAGE_NUMBER}) -> AVAILABLE TIME = REPORT
It's works to me.