When designing some reports which were expanding on multiple pages the need of numbering the pages occured.  The first thing to do was to search the internet and see how others managed this problem. The first idea that popped out was to use the Page X of Y tool from iReports located in the Palette view. It was a very easy and straight forward approach because there was no need to implement additional functionality, just a simple drag and drop to the Page Footer band and some additional tweaks just to look god.

However this approach proved to be a bad one when the page number grew to a 2 digit number and the two text fields overlapped and lost their alignment. Even more, on the last page of the report the page number was not shown. To properly solve this problem the RationalPlan team found a new way to show the page number on each page including the last one.

For showing the page number on the last page of the report the Last Page Footer band must be added by right clicking on it in iReports in the left panel called Report Inspector. After having both bands active (Page Footer and Last Page Footer) drag and drop the Page X of Y tool from the Palette view to the Page Footer band. Resize each text field to look like in the picture and align the text to right respectively to the left in each text field. Now the expression of each text item must be slightly changed by right clicking the text items and writing “Page ” + $V{PAGE_NUMBER} in the first one and ” of ” + $V{PAGE_NUMBER} in the second one. Make sure that the first text item has the evaluation time set to Now and the second one to Report. This setting is located in the Settings view in the Text field properties category.

The last thing to do is to copy the first set of the text items and paste it over the Last Page Footer band and align them accordingly and this is it. Now the text will appear as it should be regardless of the number of pages and the last page will be also numbered. Good luck!