If it's a form, there is a guy who is definitely at the bottom of the page. ** Number of pages **.
JasperReport has a system variable called Variables, The user can copy the numbers that the system spits out to the form. Let's do it
This is the form I used until the last time.
I want each page, so I will display the page footer.
What i want this time ** Current number of pages ** and ** Total number of pages **.
Therefore, place two text fields.
Let's set Variables in the placed text field
Maybe I want a footer like this.
1/2
Let's achieve this. In Expression in the text field on the left
$V{PAGE_NUMBER} + "/"
In the text field on the right
$V{PAGE_NUMBER}
Let's set.
Don't forget to set the font
If 5 pages are printed as it is 1/1 2/2 3/3 4/4 5/5 Will be printed.
It's natural because the same variable is specified.
To avoid this, change the settings in the text field on the right.
Please open ** Source ** of the form.
I think that such a screen came out. This xml file is the identity of the jrxml: form file.
You used to operate this with GUI tools.
Tweak the source to get the ** total number of pages **.
Look for the
(I intentionally add xml as an extension to add color.
Blank_A4.xml
<textField>
<reportElement x="520" y="35" width="34" height="14" uuid="a26088d6-0466-4753-b5ba-8932673a1ecf"/>
<textElement>
<font fontName="IPAexg"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
Add attributes to the textField tag here. Please edit like this.
Blank_A4.xml
<textField evaluationTime="Report">>
<reportElement x="520" y="35" width="34" height="14" uuid="a26088d6-0466-4753-b5ba-8932673a1ecf"/>
<textElement>
<font fontName="IPAexg"/>
</textElement>
<textFieldExpression><![CDATA[$V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
This evaluationTime is an attribute that edits the evaluation timing. The default is Now, which is set to display the current number of pages. Change this to Report and change it to get the total number of pages in the report.
Let's execute it after setting.
The number of pages is printed properly.
Recommended Posts