Java, Software Development

iReport 2.0.0 Page Numbers and Page Count

java Sort Enum Properties Monitor Directory File Lambda Expression parameter return types Validate XML String XSD ExecutorService AutoCloseable Try-With-Resources Convert LocalDateTime OffsetDateTime Run Codes Before Shutdown XML Tag Lambda PostgreSQL JDBC invoke JavaScript Applet SFTP Batch hang block main thread MySQL JDBC try-with-resources delete Unencrypted SoapFault Apache CXF Remove XML Element XSLT skip execute finally public static void main constructor fields Eclipse convert Iterator Stream StreamSupport XMLEncoder XMLDecoder rename P6Spy JDBC Example PDF Version JasperReports Run from Ant iReport Page Numbers Count entities persistence context hibernate
This post shows how to create a jasper report using iReport that displays page numbers and page count, e.g., 1/10. Moreover, the iReport will show the page numbers and page count on top of the pages.

iReport 2.0.0 and other requirements

We used the following items for this post.

  • Windows 7 Professional SP1
  • Eclipse – Kepler Release
  • Java 1.7 (1.7.0_67 – Windows x86)
    1. NOTE: Set source target and level is Java 1.6
    2. We have not tested it yet with source target and level 1.7
  • JasperReport 3.1.4
  • iReport 2.0

Using iReport 2.0 To Display Page Numbers and Count

iReport 2.0.0 is ancient, but it serves its purpose, at least, in the application I maintain. It is so old I started to think I was hitting an unresolved bug while struggling to generate the correct page numbers and count. But I was wrong.

To generate something like “1 / 2″, i. e., page one of two pages, use only $V{PAGE_NUMBER} for each number evaluated at Page Time and Report Time.

ireport2-0-0_page_number_page_time1

Evaluate at Page Time

 

ireport2-0-0_page_number_report_time1

Evaluate at Report Time

 

Notice the report we generated using iReport – it displays the current page and the total page count.

ireport2-0-0_page_number_sample01

Sample generated PDF

This is also, of course, applicable to later versions of iReports.

Got comments, or suggestions? Please visit our Facebook page!

You Might Also Like