ProductsAI & Analytics

Custom/Dynamic Page Breaking in BIRT

BIRT’s standard options for page breaking is to set a page break interval on a table, set a before/after page break on groups, and to set before after page breaks on report items. But what if you want to set a page break after every 2, 3, etc. groups? One way is to create an interval group surrounding your group you’d like 2 or 3 of and page break after it. Say you choose this approach and your 2nd or 3rd group goes a couple lines over your page size. You wrap the last group to the next page for a couple lines and then the interval group page brake happens and you waste a good portion of a page.

Another way to handle this is to use script to force page breaks after every 2 groups by incrementing a variable keeping track of the groups per page. You can also keep track of the items in the group using an aggregation. If the rows in the 2 groups you had planned to put on one page go over the predetermined amount of rows a page can hold, you can manually force a page break between the two groups in the group’s onCreate method with the code this.getStyle().pageBreakBefore = “always”. If they will both fit, you’d set a page break after the 2nd group with the code, this.getStyle().pageBreakAfter = “always”. In your onPageBreak script for your group, you’d reset your count variables for the groups and for the rows. This would mean that if after you force the page break, your group/row counts would start over on the next page.

Another thing you could do would be to only keep track of the rows in a group. If 3 groups fit on one page, you wouldn’t have to force a page break until before the 4th group. Then, if only two fit on the next page, your manual row count would let you know and you’d be able to page break before the 6th group, giving you a manual interval and no splitting of groups between pages, unless a single group spanned more than one page.

Also, when using the standard “page break interval” feature on a table, group headers are not counted in the row count for a page, just the detail rows. If you kept a manual count of rows, including the group header rows, you could use the pageBreakBefore script above in your row’s onCreate script to manually page break when you’ve reached your maximum lines that can fit on a page.

A simple example showing how to do the manual interval group of groups can be found in the devShare at the link below.


OpenText is the leader in Enterprise Information Management (EIM). Our EIM products enable businesses to grow faster, lower operational costs, and reduce information governance and security risks by improving business insight, impact and process speed.

Related Posts

Back to top button