Home
Analytics
Hide based on Page Number
dan3874
I am adding a bar code to my report and it should only print on the first page of the report. So, in the master page I selected that bar code and went to the script and entered this value for "On Render".
if(pageNumber > 1){
this.getStyle().display ="none"
}
That did not do anything. So, I then tried referencing pageNumber in the "Hide" tab for that bar code, still nothing!
Please tell me how to make this work! Thanks in advance.
Find more posts tagged with
Comments
mwilliams
That should be the way to do it. The question is, is your pageNumber variable being incremented? What is your BIRT version? Do you force a page break going from page 1 to page 2 and so on? Or is it hitting the end of the PDF page and just breaking on its own? If you run this in the web viewer, does it work? Let me know.
dan3874
Michael,
This doesn't make any sense to me. I just built the report and let it create the page breaks as needed. If I run it in the web viewer then the bar code only displays on page one. However, as soon as I ask it to print a PDF, the bar codes appear on each page, even thought the paging looks the same in the web viewer and the PDF.
What am I missing???
dan3874
Oh, my BIRT version is 2.6.1
mwilliams
There is a bug with the end of page events being ran in this version which causes the pageNumber variable to not be incremented. It's fixed in BIRT 2.6.2. If you set a page break interval that will definitely fit on a page in PDF, it should work. Or, if you can upgrade to 2.6.2, it should work. If you upgrade, be sure to use the "fixed" layout if working with PDF and auto breaking.
Hope this helps.
qos
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75340" data-time="1301604162" data-date="31 March 2011 - 01:42 PM"><p>
There is a bug with the end of page events being ran in this version which causes the pageNumber variable to not be incremented. It's fixed in BIRT 2.6.2. If you set a page break interval that will definitely fit on a page in PDF, it should work. Or, if you can upgrade to 2.6.2, it should work. If you upgrade, be sure to use the "fixed" layout if working with PDF and auto breaking.<br />
<br />
Hope this helps.<br /></p></blockquote>
<br />
Hello, <br />
<br />
I am having a similar problem but only since upgrading to BIRT 2.6.2 . We did the upgrade so we didn't have to specify a page break interval to use page variables. Everything worked fine except for hiding a grid in master page footer based on native page variables when exporting to pdf, in web viewer its ok. It worked fine in 2.6.1. We have the following script in the event onRender of the grid <br />
<br />
if (BirtComp.equalTo(pageNumber, totalPage))<br />
{<br />
this.getStyle().display = "NONE";<br />
} <br />
<br />
What has changed and how do we solve this?<br />
Thanks in advance
mwilliams
Yes, this seems to be a new bug. I believe it's been logged, but you can log it again and they'll join yours to the other. Is there any way that you can put the contents of your footer into a page variable? Then use the autotext to display it in the masterpage? You can change the value of the page variable in the onPageStart or onPageEnd methods and these changes will be reflected in the masterpage. So, if you make the value "", it will show as nothing for that page.
qos
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="77679" data-time="1306517529" data-date="27 May 2011 - 10:32 AM"><p>
Yes, this seems to be a new bug. I believe it's been logged, but you can log it again and they'll join yours to the other. Is there any way that you can put the contents of your footer into a page variable? Then use the autotext to display it in the masterpage? You can change the value of the page variable in the onPageStart or onPageEnd methods and these changes will be reflected in the masterpage. So, if you make the value "", it will show as nothing for that page.<br /></p></blockquote>
<br />
Hello, <br />
<br />
Thanks for your answer. It's a grid (with some complexity) that we want to hide so putting footer contents into a page variable it's a little bit difficult...... I made another experience, removing the page variables condition to see if the problem was on page variables or the style (left only the instruction 'this.getStyle().display = "NONE";') and the result in PDF output is that the section is hidden in first page and shown in the others instead of hidding in all of them. I will log it. <br />
Anyway, we really need to get this going, any other hint on how we could have a workaround?...
qos
Hello,
Already logged the bug :
https://bugs.eclipse.org/bugs/show_bug.cgi?id=347629
The only one I found that seemed alike (but not the same) was
https://bugs.eclipse.org/bugs/show_bug.cgi?id=345555
.
mwilliams
It seems that you can show only on the first page and not on the rest in PDF, but any other setup doesn't work. I also tried setting this.getStyle().visibleFormat = "all"; Again, this works in the web viewer, but not in PDF. This seems to be a big issue. Lots of people are having problems with it, so if I find a workaround I'll post in the devShare. Hopefully it'll be fixed in the next version. It should be out in the next couple months.
qos
Hello Michael,
Just to let you know that it is already fixed (I have tested) in daily build 3.7.0.v20110519-0630. Thanks for your concern.
Download available at
http://download.eclipse.org/birt/downloads/build.php?build=M-R1-3.7RC2-201105241634
.
mwilliams
Awesome! Thanks for the update!
willy27
<p>Hello Michael,</p><p> </p><p>I've got the same sort of trouble with Birt 4.2.2:</p><p>my report consists of a table with goups, and</p><p> </p><p>I want to have a background image but only in the first page of the PDF output.</p><p>So I tried to set the image in masterpage background as well as in the table background, but the pagebreak events fire too late in the process, and I am unable to hide the backgound image in the following pages...</p><p>Note: the page breaks are auto page breaks</p><p> </p><p> </p><p>Is this behaviour just possible in fact, or should I give up this idea ?</p><p> </p><p>Thanks in advance,</p><p>W.</p>
mwilliams
<p>Can you attach a sample report using the sample database that shows what you've done?</p>
jsekhon
<p>I am having the same issue for Masterpage on Eclipse 4.4.0. Works on BIRT report viewer and not on pdf.</p>
<p> </p>
<p>Thanks,</p>
<p> </p>
<p>Jaslin Sekhon</p>
JFreeman
<p>Can you attach a sample report based on classic models or a flat file data source that demonstrates your configuration and replicates the issue?</p>
jsekhon
<p>If I add this script in Master page </p>
<p> </p>
<div>if(pageNumber != 1){</div>
<div>this.getStyle().backgroundColor = "BLACK";</div>
<div>}</div>
<div> </div>
<div>the page number is not incremented. It works fine in web viewer but running as a pdf it does not work.</div>
<div>I have read about separate run and render tasks. Is this a defect in BIRT.</div>
<div>Moreover page breaks don't work in birt. The workaround is separate masterpages.</div>
<div> </div>
<div>Please help. </div>
JFreeman
<p>You hit the nail on the head with separate run and render tasks, that is what will need to happen versus using a RunAndRender task.</p>
<p> </p>
<p>To my knowledge, this is not a bug but has to do with being a single versus separate tasks. However, it would not hurt if you want to file a bug report to request a change to handle this as desired in RunAndRender.</p>