Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
PDF Page Break Problem when hiding rows
RobR
Hi: <br />
<br />
I have a report which I created that is causing page break problems when it is rendered as a PDF.<br />
<br />
The report is showing a Hierarchy of data: Think of an Org Chart: Mgr A has Employee B who has Employee C & D & E, etc. There is a max of 7 levels so I know the number of columns. <br />
Each line of the report should show the Employee ID and their name of the lowest employee in the tree at that level (The "...." are not in the report, just included to get the formatting right in this post).<br />
<br />
<span style='font-family: Courier New'>ID-1....MgrA Full Name<br />
........ID-2....EmpB Full Name<br />
................ID-3....EmpC Full Name<br />
................ID-4....EmpD Full Name</span><br />
<br />
What I struggled with is that the first line of a new page must show the Hierarchy of the first employee on that page. For Example, if a page break occurs after EmpD, the next page must look like:<br />
<br />
<span style='font-family: Courier New'>ID-1....ID-2<br />
............ID-5 EmpE Full Name</span><br />
<br />
I thought I had the problem solved by making a Detail Row that had the "1st Row" that contained only the ID numbers, and then hide it except after an onPageBreak.<br />
<br />
<strong class='bbc'>onPageBreak Expression</strong>:<br />
reportContext.setPersistentGlobalVariable("showDetail","true");<br />
<br />
<strong class='bbc'>Row Visibility Expression:</strong><br />
var hide_row = true;<br />
<br />
if (reportContext.getPersistentGlobalVariable("showDetail") == "true") {<br />
reportContext.setPersistentGlobalVariable("showDetail", "false");<br />
hide_row = false;<br />
}<br />
<br />
hide_row;<br />
<br />
But: When I render the report as a PDF, I get pages that are not fully filled (like 1-7 lines)<br />
<br />
Is there another way of accomplishing this with Birt 2.3.2 (upgrading is not an option)? <br />
<br />
Thanks in advance, <br />
<br />
Rob
Find more posts tagged with
Comments
mwilliams
Are there many hidden rows? I remember a bug where hidden rows still took up space for whatever reason. Any chance you can recreate the issue with the sample database?
RobR
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78537" data-time="1308153327" data-date="15 June 2011 - 08:55 AM"><p>
Are there many hidden rows? I remember a bug where hidden rows still took up space for whatever reason. Any chance you can recreate the issue with the sample database?<br /></p></blockquote>
<br />
Insightful question, as a matter of fact I have a hidden row for each level of the hierarchy. I did this because of the formatting of the report (The Employee name must span multiple columns of the table because of its size). So I am only showing 1 of the 8 detailed rows for each row in the database.<br />
<br />
When I deleted all of the hidden detail lines, except for the one detail row containing the "1st Row", the problem got much better-only one line overflows ever 2 pages (versus 1-7 lines every page). Still not acceptable, but it seems to confirm your suspicions that the "invisible" row is taking up space.<br />
Is there a way around the bug (other than upgrading)? Or is there a different technique I can use to get the needed info into the first line of each page of the report other than hiding/unhiding a detail row? <br />
<br />
PS: I'll hold off trying to create a sample report since the problem does appear to be caused by a known bug. Unless you still feel it is necessary.
mwilliams
Instead of hiding the row with the visibility property, you could try setting the display property for the row in your onCreate script after checking your conditions the same as you do in the visibility property:
this.getStyle().display = "none";
RobR
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="78569" data-time="1308173649" data-date="15 June 2011 - 02:34 PM"><p>
Instead of hiding the row with the visibility property, you could try setting the display property for the row in your onCreate script after checking your conditions the same as you do in the visibility property:<br />
<br />
this.getStyle().display = "none";<br /></p></blockquote>
<br />
Thanks for the suggestion but:<br />
<br />
this.getStyle().setDisplay("none");<br />
<br />
Still causes the page breaks in a PDF to be off. The HTML and Viewer are correct so I may have to convince the client to live with that.
mwilliams
Can you attach your PDF output? I just made a report with 8 detail rows and hid 7 of them and it didn't leave large spaces except where the page break interval was more than what could fit on the PDF page, every other page had a few rows and then a page break.
RobR
Posting the actual report would get me fired, so I dummied up the report using hardcoded values.
The Page Break Interval is set to 35 (pb35.pdf) or 30 (pb30.pdf)
Even at 30, I get overflows occasionally (not to mention a large amout of white space at the bottom of some pages.
It seems setting the Page Break Interval to 0 causes the onPageBreak event not to fire (which is how I controlling making the "fake heading" row visiable.
This PDF was created with setting
this.getStyle().setDisplay(row_style);
in the onCreate of the Row
Thanks.
Rob
mwilliams
Yeah, your issue is more like the one I described in what I saw. Based on showing and hiding, you're sometimes overrunning your limit. This is a bug in which even though there is a natural page break, BIRT doesn't consider it and keeps counting the page break interval. When it hits the interval, it breaks, even if it's 1 line into the physical page. This is fixed in newest versions, though that won't help you if you can't upgrade. The only way I see to solve your issue is probably going to be to keep your own "line count" in script and force the page breaks yourself when you're reach the line limit on your page.
To do this, you'd simply initialize a variable to 0 in your initialize method. Then, in the onCreate event of the row, you'd determine if you're hiding or showing this row. If you're not hiding, you'd increment your lineCount variable. When you reach your limit of lines that will fit on a page, you'd set your pageBreakAfter to "always" and reset your lineCount variable. This will cause the onPageBreak events to fire. If your rows can have long text that cause multiple lines, this can get messier, but you can set up a good approximation of lines based on characters and increment your variable with the appropriate calculated line count for that row. Let me know if you have questions.
RobR
Michael:
Thanks for all your help. My problem isn't "solved" but at least I know what's going on and my options going forward.
Maybe I'll get ambitious and dynamically build my own columns and rows...or maybe not ;-)
Thanks again.
Rob
mwilliams
Good luck. Let me know if you run into any issues on this!