Using a page number string
For Page Number containers, use the Text Expression property to create a page number string, such as the standard "Page N of M".
If you set the Text Expression property, it is important to verify that the Page Number container length is long enough to print the full page number text. The size of the string depends in part on the number of page breaks in the report. For example, the string "Page 2 of 5" has a smaller length than "Page 2 of 76".
Because of the unpredictable variation in size, Genero Report Writer defaults to a container size based on a four digit current page and total number of pages ("Page 9999 of 9999"). To override the default behavior you can set the X-Size to an explicit size or specify a smaller size with the Text property (for example "Page 99 of 99").
The values of the Name (pageName), Offset (pageNoOffset), and Format (pageNoFormat) properties are ignored when the Text Expression property is set.
These functions can be used to format and access specific page numbers and totals.
- Class String: format(Numeric number, Enum format) - formats the number as specified. The value for the format parameter can be ARABIC, LOWERROMAN or UPPERROMAN.
- Class Numeric: getPhysicalPageNumber() - gets the current page number of the physical page.
- Class Numeric: getTotalNumberOfPhysicalPages() - gets the total number of physical pages.
- Class Numeric: getPageNumber(String pageName)- gets the page number of the specified page
- Class Numeric: getTotalNumberOfPages(String pageName) - gets the total number of pages
for the specified page.Note: If you use functions
getTotalNumberOfPhysicalPages()
orgetTotalNumberOfPages()
and if printing is initiated from the viewer, report pages waiting to be updated with the actual page count will be held back.
Examples
This expression computes the string "Page N of M" for the physical pages. The equivalent of the
Offset property can be achieved by doing arithmetic with the results
from the page number functions. In this case, the numbering starts at page 11 since the example
formula adds 10 to the value returned from the function
getPhysicalPageNumber()
;
"Page "+format(getPhysicalPageNumber(),ARABIC)+" of "+format(getTotalNumberOfPhysicalPages(),ARABIC)
This expression computes the string "Page N of M" for logical pages, providing page numbers for each order within a batch of several orders:
"Page "+format(getPageNumber("pageRoot"),ARABIC)+" of "+format(getTotalNumberOfPages("pageRoot"),ARABIC)