Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Page break with different background image for each page
Prabith
Hi,<br />
<br />
I am trying to prepare a report with different background image for each page. Page break is based on data set column values. <br />
<br />
In first step I tried to set a background image for a page dynamically.<br />
<br />
For that purpose I did the following in onRender of table element<br />
but I am getting "missing ; before statement" error in line 2<br />
<br />
1: importPackage( Packages.org.eclipse.birt.report.model.api );<br />
2: SimpleMasterPageHandle simpleMasterPage = (SimpleMasterPageHandle)ReportDesignHandle.findElement("Simple<br />
MasterPage"); <strong class='bbc'>//missing ; before statement</strong> <br />
3: simpleMasterPage.setBackgroundImage("images/watermark.JPG");<br />
<br />
Thanks,<br />
Prabith
Find more posts tagged with
Comments
mwilliams
Hi Prabith,
If your report has a list or table that spans multiple pages, I don't believe you'll be able to change the background image per page because the master page is only created once. You would have to have a different element on each page to attach a different masterpage to. In 2.6, there is supposed to be the ability to switch master pages within a single element.
Prabith
Hi MWilliams,
Thanks for your quick replay.
Yes, i designed report using table.
I have one more doubt, Is it possible to read an element value using java script like
CurrentPage -> element by name -> element value
After reading that value I need to control page break using java script
Thanks,
Prabih
mwilliams
Prabih,
So, you want to page break after you encounter a certain value in your table? Is this what you're trying to do?
What is your BIRT version?
Prabith
Hi MWilliams,
Yes you are correct, that i am trying to do. I am using birt version 2.2.1
Thanks,
Prabith
mwilliams
Prabith,
The attached report shows how you can check a table value and page break after it. In this example, I page break after each time the creditlimit is 0. Let me know if you have questions.
Note: For some reason, the report will not upload. I'll try again later. If it doesn't work, I'll figure out what's up and then attach it.
Prabith
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="65945" data-time="1277588030" data-date="26 June 2010 - 02:33 PM"><p>
Prabith,<br />
<br />
The attached report shows how you can check a table value and page break after it. In this example, I page break after each time the creditlimit is 0. Let me know if you have questions.<br />
<br />
Note: For some reason, the report will not upload. I'll try again later. If it doesn't work, I'll figure out what's up and then attach it.<br /></p></blockquote>
Prabith
Hi MWilliams,
I am going to update birt to 2.6 version. I think I can solve both above issues, Can I ?
Thanks
Prabith
mwilliams
Prabith,
Theoretically, yes. I have not tested 2.6 to see if the master page switching works and what situations you're able to switch it in. You can always download it and try it out.
Uploading a file failed for me again. So, I'm going to try to figure that out. I'll post the design file when I can.
mwilliams
Found the upload issue. Had to zip it up to get the 2.2.1 design to upload. Not sure why this was, but, check out the attached file.
Prabith
Hi MWilliams,
Page break issue is solved with the help of your uploaded file, thank you very much.
I have updated report engine to 2.6, it is working fine now.
Back ground image issue is still pending. Please help me for that also.
I have written following code in onPagestart event of report
importPackage( Packages.org.eclipse.birt.report.model.api );
var simpleMasterPage = ReportDesignHandle.findElement("Simple MasterPage");
simpleMasterPage.setBackgroundImage("images/watermark.JPG");
but i am getting following exception.
20:36:25,093 WARNING [ScriptExecutor] There are errors evaluating script "importPackage(
Packages.org.eclipse.birt.report.model.api );
var simpleMasterPage = ReportDesignHandle.findElement("Simple MasterPage");
simpleMasterPage.setBackgroundImage("images/watermark.JPG");":
Java class "org.eclipse.birt.report.model.api.ReportDesignHandle" has no public instance field or
method named "findElement". (/report/method[
@name="
;initialize"]#3)
org.eclipse.birt.report.engine.api.EngineException: There are errors evaluating script
"importPackage( Packages.org.eclipse.birt.report.model.api );
var simpleMasterPage = ReportDesignHandle.findElement("Simple MasterPage");
simpleMasterPage.setBackgroundImage("images/watermark.JPG");":
Java class "org.eclipse.birt.report.model.api.ReportDesignHandle" has no public instance field or
method named "findElement". (/report/method[
@name="
;initialize"]#3)
at
org.eclipse.birt.report.engine.script.internal.ScriptExecutor.addException(ScriptExecutor.java:158)
at
org.eclipse.birt.report.engine.script.internal.ReportScriptExecutor.handleInitialize(ReportScriptExec
utor.java:53)
Thanks & Regards
Prabith
mwilliams
Prabith,
What is your goal with changing the master page? Are you wanting the first page on a different master page than the rest or something like that? Let me know. I'll see if the master page switching happened in 2.6 after you let me know.
Prabith
Hi Williams,
I want to create a report with water mark background image, but some pages do not need image on backgorund(condition is based on row data).
Thanks & regards
Prabith
Prabith
Hi Williams,
I think you are understood what i have posted last. I am expecting your reply, if anything couldn't understand please let me know.
Thanks & regards
Prabith
mwilliams
Prabith,
Sorry for the delay. I was out most of last week with meetings. If changing the master page depends on data on the page, doing so will depend on BIRT 2.6 having the ability to switch master pages. I'll check to see if the feature made it into 2.6 and then post back in here.
mwilliams
Prabith,
It looks like switching master pages independent of switching report elements didn't make it into 2.6.0. You can submit an enhancement request for a feature like this at
http://www.birt-exchange.org/org/resources/bug-reporting/
.
ThatRandom
I have run into a similar problem with a report I have to now write - has this functionality been added in 2.6.2 or has a workaround been discovered?
I have five backgrounds, each representing a different sport. Depending on a dataset, I would like to choose which one has to be used as the background image for a page in a multi-page report. I've read about somehow using beforeFactory and onRender events to achieve this (wasn't sure if this was applicable due to it being a page background?), and haven't found a way to use this in 2.6.2...
mwilliams
So, you'll only use one masterpage in the report? You just need to choose? If so, depending on what dataSet you use, which I'm assuming will be decided by a report parameter, you can set the masterpage of the first element in the report in its onCreate script with this.getStyle().masterPage = "myMasterPage". As long as you haven't set the masterpage on any of the following elements in the report, they'll all follow the masterpage you set in the first element. Hope this helps. Let me know if I understood incorrectly.
ThatRandom
I'm undecided at the moment which is the better way to go, hence why I came here
I'm still so green I'm not even sure that the functionality you described for Prabith is available in 2.6.2.
Essentially what I have is a list of (around 130) clients who I have to send a physical newsletter (so I'm making a single PDF containing all clients: one page per client). In my (top-level) dataSet is one field which represents that client's favourite sport. Based on this field, I'd like to change the background image.
Are you saying that it could be simpler to have this one report choose between various master pages? Since there are multiple users with different backgrounds in one PDF file, how would this affect your decision. Please ask if you require further detail, any help is greatly appreciated.
mwilliams
Unfortunately, you can't switch the masterpage within a single element, in 2.6.2. I haven't looked if it made it into 3.7 or not. So, you've got a report in which you want to change the background of the page depending on a value from the dataSet for the current group? Could the background image just be in the table? Or do you want it for the whole page?
ThatRandom
The whole page, if that's possible?
mwilliams
The problem still exists of changing the masterpage within a single element, so I don't know if there will be a way to do that. I guess you could potentially run the report individually for each group and join them together afterwards. I'll take a look at a solution for this and let you know.
mwilliams
This may be as close as you'll get. I use a subtable in a grid that is sized to fit the page. In the outer table, I change the background image depending on the customernumber in the outer table. The odd ones show one image and the even show another. The background image is for the group footer which I have stretched out to fit the page with the grid. Hopefully this helps. Let me know if you have questions. The images aren't pretty. They just happened to be two I had in my workspace.
ThatRandom
That works brilliantly for my application, thank you!
The thing which may put people off this solution is that it only applies to the page in between the header and footer of the masterpage (which luckily my background did).
mwilliams
Glad it worked for you. You can always create an enhancement request to be able to switch masterpages within a single element at
http://www.birt-exchange.org/org/resources/bug-reporting/
. This would handle your situation perfectly if it were possible.
Let us know whenever you have questions!