ISSUE: Page number is not displaying on all pages in the report. Report contains three subreports. Specifically, the preview displays Page 33 of 38 or Page 24 of 25.
I expected the report to display 1 of 38, 2 of 38, 3 of 38, 4 of 38, 5 of 38, so on.
Within the "Page Footer" section of the Report Inspector, I create this text field.
"Page " +$V{currentPage}+" of " + $V{PAGE_NUMBER}
Expression Class is java.lang.String
Evaluation time is Auto
Note: I created variable $V{currentPage} with class = java.lang.Integer, Calculation = Nothing, Reset Type = Page, Variable Expression = $V{PAGE_NUMBER}, and all other properties are default values.
What am I doing wrong? What specific steps should I perform to have page numbers display on every page instead of the last few pages. Thanks.
3 Answers:
The issue is that $V{PAGE_NUMBER} does not account for sub-reports. You will need to update the page number expression and use the $V{MASTER_CURRENT_PAGE} and $V{MASTER_TOTAL_PAGES} built-in variables. Also, set the evaluation time on that expression to Master.
<textField evaluationTime="Master" isBlankWhenNull="true"> <reportElement x="760" y="12" width="150" height="13" forecolor="#000000" backcolor="#FFFFFF" uuid="02a85f92-befb-40fc-b214-9099b4d17de8"> <property name="com.jaspersoft.studio.unit.width" value="px"/> <property name="com.jaspersoft.studio.unit.height" value="px"/> </reportElement> <textElement textAlignment="Right"> <font fontName="Arial" size="8"/> </textElement> <textFieldExpression><![CDATA["Page " + TEXT($V{MASTER_CURRENT_PAGE}, "#,###") + " of " + TEXT($V{MASTER_TOTAL_PAGES}, "####")]]></textFieldExpression> </textField>
I failed to mention that I am working with Jaspersoft iReport Designer 5.6.0. Would the page number solution be different for this Jaspersoft iReport version? Thanks again for any direction.