Search code examples
jasper-reports

Footer printed when page number is pair. Leaves blank space on other pages


I'm having some issues with JasperReports. I have a page footer that only prints when $V{PAGE_NUMBER}.intValue() % 2 == 0 .

This works correctly, but the main issue is that the page footer always occupies its fixed height, wether it is printed or not.

This behaviour makes me really sad, because my boss wants "these to be done well and for yesterday", but that extra space on unpair pages is making my reports not really very good looking: my page footer is really tall (height of 200px, more or less) and the blank space it leaves on odd pages is too big.

I tried almost everything I could read regarding this issue, but couldn't find a solution. I tried to move the contents of the page footer to a detail band and try to print that band at the bottom of the page when the page number is odd, but this solution didn't really work.

I would appreciate any kind of help. Please reply or my boss kills me.


Solution

  • The pageFooter and columnFooter are bands that do not allow overflow, the report engine calculates there size not on content but on band height which means that they will always be present with the band height you set...

    Quoting Teodord jasper report staff

    "I'm afraid there is no solution for what you want to achive"

    This is in fact why jasper report introduced lastPageFooter, to enable the possibility to have a footer only on last page. Furthermore there was a feature request for firstPageFooter.

    But it has been closed, no changes required, use negative coordinates, background band...

    Conclusion:

    You need to re-think you report structure, is there any logical grouping on which you can add a groupFooter you can stack it to the bottom footerPosition="StackAtBottom", or leave it as it is and go home ; )

    Don't try to foul jasper report by grouping on $V{PAGE_NUMBER}.intValue() % 2 == 0, unfortunately it will not work..., you need to find

    • a logical grouping within your fields (data) or

    • on the number of records present in page $V{PAGE_COUNT}>20 or

    • something like $V{PAGE_COUNT}>15 || ($V{PAGE_NUMBER}%2==0 && $V{PAGE_COUNT}>10) that actually works breaking differently every odd page, leaving you the space after 15,10 records.. (note space is not really controlled if you isStretchWithOverflow="true" on the textField in detail band)

    so go home....