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 min read

QR code and smartphone, new technologies. Electronic digital technologies scanning, barcode
QR code and smartphone, new technologies. Electronic digital technologies scanning, barcode

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

Can CIOs meet today’s challenges and plan for tomorrow?

Can CIOs meet today’s challenges and plan for tomorrow?

Read the new white paper

April 21, 2025

4 min read

From the Great North to global innovation: How OpenText powers the future of tech

From the Great North to global innovation: How OpenText powers the future of tech

The beginning of the year is the perfect time to reflect on one’s successful journey and set our sights on the future. At OpenText, our…

February 28, 2025

3 min read

Why SAST + SCA is the key to protecting your organization in 2025

Why SAST + SCA is the key to protecting your organization in 2025

Software supply chain risk continues to rise—just last year we witnessed a staggering 156% year-over-year increase in malicious software supply chain attacks.

January 17, 2025

4 min read

Stay in the loop!

Get our most popular content delivered monthly to your inbox.