Jump to content
We've recently updated our Privacy Statement, available here ×
  • Bands larger than one page


    djohnson53
    • Version: v5.1, v5.0, v4.8, v4.7, v4.6, v4.5 Product: JasperReports® Library

    Sometimes the content of a particular report band is larger than one page and we have to find a way to force page breaks at certain points, inside the band structure. Of course, this issue does not concern all the report bands. I imagine that we shall never have page or column headers or footers larger than one page ... but who knows?

    If the title band or the summary band are larger than one page, you should consider placing their content into a subreport element and applying the following trick to this particular subreport. This might even work for the page or column headers, but never for the page or column footers, since the engine judge them to be of fixed height and do not perform stretch for the elements placed on those sections.

    We have eliminated from our discussion some of the report sections and all that remains are the group headers and footers and the detail band.

    The group headers and footers will be treated together, so let's start with the detail band.

    If we have a detail band that contains so many elements on it that we have to split it on multiple pages, we have to find a way to introduce page breaks. But there is no such "page break" element available in JasperReports, so what to do?

    The only way to deliberately introduce page breaks in JasperReports is by using the isStartNewPage attribute of the <group> element. We cannot use this to solve our problem.

    Normally, the reporting engine starts a new page or column every time it sees that the band it has to fill does not fit on the remaining space on the current page. This is why we have that validation performed when the report design is compiled, so that the bands do not have a height greater than the page height. Without such a constraint, the reporting engine would get confused and behave uncontrollably.

    So, in order to solve our problem, we have to find a way to somehow pass this band height validation check.

    Well, we could do that by splitting the detail band content on multiple bands, each one of them smaller that one page, so that the report design remains valid.

    And what other report bands could we use? Group headers and footers of course.

    We could place some of our detail elements on a special group header, some of them will probably remain on the detail section, and the rest could go on the group footer. The only condition to this is that the group header and footer should always accompany our detail section, so that all three behave like a normal large detail band.

    That's the easiest part, because we can introduce a dummy group that will break with every row in the data source. Such a group would have an expression like the following:

    <groupExpression>$V{REPORT_COUNT}</groupExpression>

    If one dummy group is not sufficient for you and you have a giant detail band, you could introduce as many dummy groups as you want to, all of them with the same dummy expression.

    Problem solved.

    Hey, we forgot about that other situation when one of the group headers or footers is larger than one page.

    No problem. The solution is the same. You just have to introduce a new group, with the same expression as the one which poses the problem, and to split that group header or footer content between the two. Those two groups will break together and behave like one, so you can distribute the elements on their headers and footers as you want to.

    The band height validation check could be passed this way.


    User Feedback

    Recommended Comments

    There are no comments to display.



    Guest
    This is now closed for further comments

×
×
  • Create New...