BIRT Exchange Forum: BIRT Exchange Forum -> BIRT: Multiple Master Pages with no scripting

Jump to content


 

No Latest Open Poll.

BIRT: Multiple Master Pages with no scripting

Posted by Virgil  Icon, 28 February 2008 - 01:15 PM

BIRT has the ability to use multiple master pages within a single report even though there is only one Master Page tab in the report designer.



The steps below will show you how to use three different master pages within the same report without requiring any scripting. A master page is used to define the page properties, like the background color, page margins, page headers, and page footers for the report. These headers and footers often hold report metadata like the author, company copyright info, corporate logos, pages numbers, report run date, etc. that we want to appear on every page. For some reports, we may want to show different headers and footers on different pages throughout our report. For these cases, we can use the Page Break property on certain report controls to decide which master page to use. To get started, we first need to create our master pages. The first one is easy to figure out since we can use the Master Page tab. You can add items to both the page header and page footer areas within a master page. There are also several auto text elements to choose from like a "page x of x" auto text control. You will notice that you have to use a grid in order to add multiple items to the header or footer. You can add additional master pages from the report outline view by right-clicking on MasterPage and selecting "Insert Element". You can add as many Master Pages as needed for the report.



Each MasterPage has a unique name. To edit one of the Master Pages, double-click it. Once you have your master pages created, you can control which master page is used in the Page Break property of several different BIRT controls.



For this example, I am going to use a grid to define when to switch my master pages. Everything I put in the first row of the grid, I want to appear on the first page and use one Master Page. I have a table in the second row of the grid. I expect this table data to spread across multiple pages and I have another master page that gets applied to every page... and finally, the third row in my grid will appear on the last page of the report and I have a third master page for this content. The picture below shows the three grid rows.



To assign the master pages, select the Grid... and then select the first row. In the Property Editor view, select the Properties tab and then the Page Break property. Select the desired master page from the drop-down list. I' selecting 'firstPage' which is the name of one of my Master Pages. Repeat these steps by selecting row 2 and 3 of the grid and selecting your alternate master pages from the list. For me, I'm selecting 'middlePages' for row 2 and 'lastPage' for row 3. Once you are ready to test these changes, be sure to pick a paginated output type, like the PDF output, or the Web Viewer... otherwise, if you select the Preview tab... or go directly to HTML, then you will only see the first master page. The page break is never called for HTML output since everything is shown on one page. By looking at the output below, you can see that the first page has one master page applied, the middle pages have another master page applied... and the last page has a third master page applied.



The finished report design has been uploaded to the DevShare area within BIRT Exchange at: http://www.birt-exch...p?cid=2&lid=321


1 Comments On This Entry

Page 1 of 1

muzy Icon

23 May 2012 - 02:01 AM
Good post
Page 1 of 1