A normal BIRT report(not chart) generally have a table whose data is going to be spread over hundreds of pages. For example a sales report may have a table with columns like product name, price, count and purchase date. And that table may have thousands of rows that will take a lot number of pages when exported to PDF.
One problem with BIRT PDF report is that if report is not properly designed (table layout) then you may end of with blank spaces at the bottom or left due to the lines per page property of the report table. By defaults BIRT allocates 40 rows of a report table in one page and then it move on to the next page. So if the table row data are less then the row height will be less and after 40 rows there will much space left on the page. On the other hand if your table rows have more data then increase in height of individual rows and eventually the page is not enough to adjust the 40 rows. In this case BIRT will squeeze the data to fit to the page(fit to page) and in this process it creates space in the left.
There are two ways this problem can be addressed. First configure BIRT to handle for you. Second, handle it yourself. I prefer the first one. Lets look both the approach.
Let BIRT Handle it -
1. Make the report layout fixed (with auto layout this will not work). Go to report property and from the general tab select the radio Fixed Layout.
2. Select the table that will contain the report data and that you think will span over pages. Open the property editor for that table, and go to the Page Break tab.
3. There, leave the Before and Inside drop down choice. For the After drop down select Always.
4. In the Page Break Interval provide 0. Do not leave it blank else it will default to 0.
5. Tick the Repeat Header choice if you want the table header on every page.
6. Make the width of the table 100%.
7. Make sure the width of the table, in the layout is fitting to the width of the report.
8. An additional check, select the table content row, open the property editor and make the Height blank.
That is all, hope I have not missed any point. The report should come fine.
Handle It Yourself -
1. For this the report layout should be auto layout.
2. Create two Report Parameters LINES_PER_PAGE and ROW_HEIGHT.
3. From the property editor for the table, give a name to the table say "report_table".
4. Now select the report (can do this by clicking on the report not any component), open the script tab from the button. At the top you should see a Script drop down.
5. From the drop down, select beforeFactory and provide the following two lines of code
mytable = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("report_table");
mytable.setProperty("pageBreakInterval",params["LINES_PER_PAGE"].value);
6. Now select the table content row and open the script tab. And select the onCreate from the drop down.
7. There provide the code this.height = params["ROW_HEIGHT"].value;
We are done with the dynamically setting of lines per page and row height. You can ask the user for these report parameter values or calculate it with some business logic.
Will improve this post if found some thing new on this topic.
One problem with BIRT PDF report is that if report is not properly designed (table layout) then you may end of with blank spaces at the bottom or left due to the lines per page property of the report table. By defaults BIRT allocates 40 rows of a report table in one page and then it move on to the next page. So if the table row data are less then the row height will be less and after 40 rows there will much space left on the page. On the other hand if your table rows have more data then increase in height of individual rows and eventually the page is not enough to adjust the 40 rows. In this case BIRT will squeeze the data to fit to the page(fit to page) and in this process it creates space in the left.
There are two ways this problem can be addressed. First configure BIRT to handle for you. Second, handle it yourself. I prefer the first one. Lets look both the approach.
Let BIRT Handle it -
1. Make the report layout fixed (with auto layout this will not work). Go to report property and from the general tab select the radio Fixed Layout.
2. Select the table that will contain the report data and that you think will span over pages. Open the property editor for that table, and go to the Page Break tab.
3. There, leave the Before and Inside drop down choice. For the After drop down select Always.
4. In the Page Break Interval provide 0. Do not leave it blank else it will default to 0.
5. Tick the Repeat Header choice if you want the table header on every page.
6. Make the width of the table 100%.
7. Make sure the width of the table, in the layout is fitting to the width of the report.
8. An additional check, select the table content row, open the property editor and make the Height blank.
That is all, hope I have not missed any point. The report should come fine.
Handle It Yourself -
1. For this the report layout should be auto layout.
2. Create two Report Parameters LINES_PER_PAGE and ROW_HEIGHT.
3. From the property editor for the table, give a name to the table say "report_table".
4. Now select the report (can do this by clicking on the report not any component), open the script tab from the button. At the top you should see a Script drop down.
5. From the drop down, select beforeFactory and provide the following two lines of code
mytable = reportContext.getReportRunnable().designHandle.getDesignHandle().findElement("report_table");
mytable.setProperty("pageBreakInterval",params["LINES_PER_PAGE"].value);
6. Now select the table content row and open the script tab. And select the onCreate from the drop down.
7. There provide the code this.height = params["ROW_HEIGHT"].value;
We are done with the dynamically setting of lines per page and row height. You can ask the user for these report parameter values or calculate it with some business logic.
Will improve this post if found some thing new on this topic.
Thanks! Helped me a lot!
ReplyDelete