Conditional Page Break
I looking for a solution for a very common situation.
I have a report with 5 different sections. Each section might have 1 or more pages (depends on data). I must ensure that a section always starts on a new page (page break) BUT I must also ensure that a section never starts on an even page.
I'm looking for a conditional page break: if current page is even => page break.
Is something like this possible???
I have a report with 5 different sections. Each section might have 1 or more pages (depends on data). I must ensure that a section always starts on a new page (page break) BUT I must also ensure that a section never starts on an even page.
I'm looking for a conditional page break: if current page is even => page break.
Is something like this possible???
0
Comments
-
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>So, are the 5 sections different tables/report items or groupings within tables? Let me know. I've not done this before, but I'll give it a shot. Also, what version of BIRT are you working with?</p></blockquote>
<br />
Yes, each section has multiple different tables/report items (no grouping).<br />
Birt version is 2.5.1.0 -
Ok. This seems to work for me. I only tested using the web viewer. Some work may need to be done to get it to work in PDF correctly, I'm not sure. I attached an example. I put a text box between each table and set its page break before to always. I set the page break before to all tables but the first to always. I initialized a variable for each text box (page, page1, page2, and page3). You can probably use just one variable and reset it in each table, but I did this for easy testing. In the page break script of each table, you increment the variable. For the visibility on the text item, you hide it if (page + 1)%2 == 1. This would mean you're on an odd page and done need the spacer. The table then starts on that odd page. If the text box is not hidden, a page break happens before it and before the next table, pushing it to the next odd page. In the attached example, ran in the web viewer, the first text box is the only one that ends up not showing cause you're on an odd page, but this shows that it works as expected. Let me know if you have any questions.Warning No formatter is installed for the format ipb0
-
Thanks!
I clearly identified the issue and I'm not sure there is a solution for it. It seems that onPageStart (nor onPageBreak) is NOT called for "auto" page breaks.
It works when "Page Break Interval" is not "0".
It doesn't work when "Page Break Interval" is "0".
To test it, simply:
1) create a table displaying a lot of entries.
2) set "Page Break Interval" on "0".
3) try to figure out how to react on "auto" page breaks.0 -
swerlen,
I had already settled on my idea to use variables controlled in the onPageBreak, so I hadn't even tried this. This is the same example, only with all script removed. The only thing done is a page break before is set to always on all but the first table. Then, for each of the 4 text boxes, the visibility expression is pageNumber%2 ==1. This works when having 0 for your page break interval because the onPageBreak event is not needed. Also much simpler. Should have done this the first time.
Hope this helps.Warning No formatter is installed for the format ipb0 -
Your example seemed too simple to work but it did!!! Unfortunately, applying the same trick on my report doesn't solve the issue. I spent hours figuring out, what was different in your example and I probably found it. You only use one single master page. My report use a different master page for each chapter.
Use Case:
1) Several Chapters
2) Each chapter consists of one or more tables
3) A chapter must always start on an odd page.
I modified your example and introduced master pages. I can now reproduce the issue. Page breaks are not applied as expected.0 -
swerlen,<br />
<br />
It seems as if the introduction of multiple master pages messes with the pageNumber variable for some reason. You can see this by changing the contents of the text box to <VALUE-OF>pageNumber</VALUE-OF>. Please log a bug on this issue at <a class='bbc_url' href='http://www.birt-exchange.org/bug-reporting/'>Report Bugs - BIRT Exchange</a>.<br />
<br />
I'll see if I can find a workaround for this issue.Warning No formatter is installed for the format ipb0 -
The bug seems to be the pageNumber variable not being incremented as expected when a table's pageBreakInterval value is < 1. Having table's pageBreakInterval set at 0, the pageNumber variable seems to only be incremented when there is a page break set to 'Always' before or after some element following the table.
Whether or not there is one or more masterpages do not influence on this.
The example in post #10 is not really working; limiting the number of row returned in the first data set "Data Set" will generate a pageBreak making blank a wrong page (page 5 is blank). The example in post #10 is the same I posted on my first post (post #2) but figured later it did not worked.
As stated in the previous post, using <value-of>pageNumber</value-of> can help show when the bug happens.
I will fill a bug report and will see for developer's response, as pageNumber is not a documented variable (is it?).
Edit: The pageNumber variable is used to count the number of page defined by the pageBreakInterval value. A table with 100 row divided by a pageBreakInterval of 25 will give 4 pages.
Thanks
Pierre0 -
Pierre,
You are correct on the example from post #10. I should have checked more scenarios, it just happened to work out perfectly that it worked correctly the first time. I didn't check the pageNumber in the text box because of that. I had checked my variables in the first example where I used the page break interval and page break script to check. I don't believe that pageNumber is a documented variable, like you said, but I would still file the bug on it still to see what they say.
Please post any bug info in here for future reference. Thanks.Warning No formatter is installed for the format ipb0 -
After looking up the Birt source code and lots of bugzilla entries, it seems more like I should do ask for a new feature instead of a bug report. Fortunately, this feature is already planned for the <a class='bbc_url' href='http://www.eclipse.org/projects/project-plan.php?planurl=http://www.eclipse.org/birt/project/plan/birt_project_plan_2_6.xml#themes_and_priorities'>next version coming in june.</a><br />
Let's hope it won't be postponed.<br />
<br />
In the meantime I patched the Birt code in the <a class='bbc_url' href='http://dev.eclipse.org/viewcvs/index.cgi/source/org.eclipse.birt.report.engine/src/org/eclipse/birt/report/engine/nLayout/LayoutEngine.java?revision=1.14.2.1&root=BIRT_Project&view=markup&pathrev=BIRT_2_5_1_Release_200909171447'>LayoutEngine</a> class starting on line 797.<br />
The patch will not output a blank page if the current page number is odd. A Text item with predefined text in it and page break before=always is used to do the trick.<br />
The patch really doesnt handle the situation in a generic fashion, it was made quick and dirty to make it work asap.<br />
If someone need it I can post it here with instructions on how to use it in the report design.<br />
<br />
Thanks<br />
<br />
Pierre0
Categories
- All Categories
- 123 Developer Announcements
- 54 Articles
- 150 General Questions
- 148 Thrust Services
- 57 OpenText Hackathon
- 37 Developer Tools
- 20.6K Analytics
- 4.2K AppWorks
- 9K Extended ECM
- 918 Core Messaging
- 84 Digital Asset Management
- 9.4K Documentum
- 32 eDOCS
- 186 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management
- 8 XM Fax
- Follow Categories