Search code examples
jasper-reports

Page Header, Page counter and Page Footer layout not working


I have a main report and a subreport i.e main.jrxml and sub.jrxml with the following problems:

  1. On second page the current page number is not incremented
  2. On second page and onwards the Title and Page Header are not fully removed
  3. On last page the Disclaimer and page number is missing
  4. .jasper file is not always re-generated for subreport in Jasper Studio, how can I make sure this is per default always re-generated

I run the reports with the Sample DB. How can I fix this?

CLARIFICATION:

For the page numbering on the TextField I use:

msg("Page {0} of {1}", $V{V_CURRENT_PAGE_NUMBER}, $V{PAGE_NUMBER})

V_CURRENT_PAGE_NUMBER is defined as follows:

Expression 1
Initial Value Exppression $V{PAGE_NUMBER}
Increment type Page 
Reset type Report

In the end I used Composite Elements for both current and total page info.

UPDATE:

Point 2: Moved Page Header content into Title.

Point 3: I solved by repeating Disclaimer and page number also in Last Page Footer. I have it now in both Page Footer and Last Page Footer.


Solution

    1. Use the Page X of Y element from the Composite Elements of the Palette view.
    2. Only the Page Header repeats on subsequent pages. You can show it only on first page with a Print When Expression like: $V{PAGE_NUMBER} == 1
    3. Duplicate the Footer elements in the Last Page Footer.
    4. From the top menu select Project > Build Automatically