In JasperReports, I like to render page numbers in the style current-page / total-pages .
Studying the official demos you can find the following solution using three TextFields
(because there is no built-in variable
for number of pages )
<!-- Right aligned current page -->
<textField>
<reportElement x="100" width="40" .../>
<textElement textAlignment="Right" ... />
<textFieldExpression class="java.lang.String">
<![CDATA[String.valueOf($V{PAGE_NUMBER})]]>
</textFieldExpression>
</textField>
<!-- Centered aligned slash -->
<staticText>
<reportElement x="140" width="5" .../>
<textElement textAlignment="Center" ... />
<text>
<![CDATA[/]]>
</text>
</staticText>
<!-- Left aligned total number pages (evaluationTime="Reports") -->
<textField evaluationTime="Report">
<reportElement x="145" width="40"/>
<textElement textAlignment="Left" ... />
<textFieldExpression class="java.lang.String">
<![CDATA[String.valueOf($V{PAGE_NUMBER})]]>
</textFieldExpression>
</textField>
However, this only works fine when the complete paging information is centered with respect to the page (with the slash in the middle). What I like to achieve is to right-align the whole group in a way that the total-pages has a constant distance to the right border.
How to achieve this?