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…

OpenText  profile picture
OpenText

March 24, 20103 minute read

Descriptive text explaining the contents of the image.

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.
https://www.birt-exchange.org/devshare/designing-birt-reports/1186-manual-group-page-breaks/#description

Share this post

Share this post to x. Share to linkedin. Mail to
OpenText avatar image

OpenText

OpenText, The Information Company, enables organizations to gain insight through market-leading information management solutions, powered by OpenText Cloud Editions.

See all posts

More from the author

Supercharge Your Data Strategy with the Latest Insights on Data and AI

Supercharge Your Data Strategy with the Latest Insights on Data and AI

Introducing the 2024 CXO Insights Guide on Data & AI Guide

October 31, 2024 6 minute read

From breakdown to breakthrough: How predictive and prescriptive maintenance are revolutionizing operations

From breakdown to breakthrough: How predictive and prescriptive maintenance are revolutionizing operations

Cut downtime, save costs, improve safety and stay ahead of failures with advanced analytics and AI-powered maintenance strategies.

October 16, 2024 7 minute read

AdTech Game-Changers: How Advanced Analytics Are Reshaping Digital Advertising  

AdTech Game-Changers: How Advanced Analytics Are Reshaping Digital Advertising  

Discover how real-time analytics empowers AdTech leaders to optimize bidding, boost performance, and impress clients.

October 03, 2024 7 minute read

Stay in the loop!

Get our most popular content delivered monthly to your inbox.