Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display page x of y in jasper report 5.5.1 in "single textfield" its giving alignment issue?

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

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

page no should be left align to left margin. i used this expression

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

but it always give output

"Page 1 of 1"

how to achieve it in single text field which is left aligned??? please help me to sort out this.

like image 321
Sandeep Sharma Avatar asked Oct 31 '22 18:10

Sandeep Sharma


1 Answers

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

Create a variable with this definition (note the resetType)

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

Page number Field (note the evaluation Time):

<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>
like image 188
mjbJasper Avatar answered Jan 04 '23 15:01

mjbJasper