How to display the x of y page in a jasper 5.5.1 report in a “single text box”, resulting in a question about alignment?

I have a situation where I need the page number in the footer in this format:

-------------------------------------------------------------------------------- page 1 of 4212 printed date: 

the page should not be left-aligned. I used this expression

 "Page "+$V{PAGE_NUMBER}+ " of "+ $V{PAGE_NUMBER} 

but he always gives a conclusion

 "Page 1 of 1" 

how to achieve this in one text field that aligns to the left ??? please help me sort this out.

+5
source share
1 answer

See: http://community.jaspersoft.com/questions/893771/printing-page-xy-single-textfield-logic-jasper-ultimate-guide-section-1922

Create a variable with this definition (note resetType)

 <variable name="currentPageNumber" class="java.lang.Integer" resetType="Page"> <variableExpression><![CDATA[$V{PAGE_NUMBER}]]></variableExpression> </variable> 

Page Number Field (note the time of evaluation):

 <textField evaluationTime="Auto"> <reportElement uuid="847e339f-a1a6-492d-868b-b233f71785b4" x="166" y="22" width="100" height="20"/> <textElement/> <textFieldExpression><![CDATA[$V{currentPageNumber} + " of " + $V{PAGE_NUMBER}]]></textFieldExpression> </textField> 
+2
source

Source: https://habr.com/ru/post/1232634/


All Articles