Inserting Background Image Problem [message #775511] |
Fri, 06 January 2012 01:06  |
Eclipse User |
|
|
|
I am trying to insert a background image using a script but cannot get it to work.
I have a grid on which I have attached the following onCreate script:
this.getParent().getStyle().backgroundImage = "DRAFT-Watermark.JPG";
The image does not show and there is no error in the debug window. I also had the full path included and it did not make a difference.
I am new to BIRT and especially new to the scripting part of the program so I may not be attaching this to the right area.
I am using BIRT 3.7 in Eclipse and I view the report as PDF directly from the designer.
The test report using the sample database and the image I am trying to insert is attached.
Thank you for any assistance,
JB
|
|
|
|
|
|
|
Re: Inserting Background Image Problem [message #775845 is a reply to message #775839] |
Fri, 06 January 2012 14:17   |
Eclipse User |
|
|
|
We have a small primer on scripting at:
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php
We need to expand this.
When you change styles in the before factory you are using the DE API
and we have a lot of examples and even a webinar on this api at
BIRT-exchange.org. Here is an example
//beforeFactory
importPackage(Packages.org.eclipse.birt.report.model.api);
importPackage(Packages.org.eclipse.birt.report.model.api.elements);
reportContext.getDesignHandle().findStyle("report").setProperty(StyleHandle.FONT_FAMILY_PROP,
"Arial");
reportContext.getDesignHandle().findStyle("report").setProperty(
StyleHandle.COLOR_PROP, "#009B9B" );
reportContext.getDesignHandle().findStyle("report").setProperty(
StyleHandle.FONT_WEIGHT_PROP, DesignChoiceConstants.FONT_WEIGHT_BOLD );
//background image
reportContext.getDesignHandle().findStyle("NewStyle").setBackgroundImage( ""
);
//or use
reportContext.getDesignHandle().findStyle("report").setProperty(
StyleHandle.BACKGROUND_IMAGE_TYPE_PROP, "" );
Jason
On 1/6/2012 2:01 PM, JB wrote:
> I am changing the background based on parameters so beforeFactory would
> actually work. Your solution of setting the backgroundImage to "" is a
> good fit for my report.
>
> One of the things that I am struggling with in learning the scripting side
> of things is the actual keywords and options for an object.
>
> For example, what would the code be to change a background in a style?
>
> I am spending hours every day just combing through websites and forums
> looking for the small snippet of code that will work for me every time I
> try to do something new. Overall though, I like the BIRT and am finding
> the support very helpful.
>
> Thanks,
> JB
>
> On Fri, 06 Jan 2012 13:38:08 -0500, Jason Weathersby wrote:
>
>> Styles can only be changed in the beforeFactory, so that is probably to
>> early if you want to changed based on data. It is not to late if you
>> want to change based on parameter. To drop the image from the grid you
>> could always use this.getStyle().backgroundImage = ""; in the onRender
>> script.
>>
>> Jason
>>
>> On 1/6/2012 1:19 PM, JB wrote:
|
|
|
Re: Inserting Background Image Problem [message #775850 is a reply to message #775845] |
Fri, 06 January 2012 14:37  |
Eclipse User |
|
|
|
Thank you very much.
I will review these references.
JB
On Fri, 06 Jan 2012 14:17:13 -0500, Jason Weathersby wrote:
> We have a small primer on scripting at:
> http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php We need
> to expand this.
>
> When you change styles in the before factory you are using the DE API
> and we have a lot of examples and even a webinar on this api at
> BIRT-exchange.org. Here is an example
>
> //beforeFactory
> importPackage(Packages.org.eclipse.birt.report.model.api);
> importPackage(Packages.org.eclipse.birt.report.model.api.elements);
>
> reportContext.getDesignHandle().findStyle("report").setProperty
(StyleHandle.FONT_FAMILY_PROP,
> "Arial");
> reportContext.getDesignHandle().findStyle("report").setProperty(
> StyleHandle.COLOR_PROP, "#009B9B" );
> reportContext.getDesignHandle().findStyle("report").setProperty(
> StyleHandle.FONT_WEIGHT_PROP, DesignChoiceConstants.FONT_WEIGHT_BOLD );
> //background image
> reportContext.getDesignHandle().findStyle("NewStyle").setBackgroundImage(
> ""
> );
> //or use
> reportContext.getDesignHandle().findStyle("report").setProperty(
> StyleHandle.BACKGROUND_IMAGE_TYPE_PROP, "" );
>
> Jason On 1/6/2012 2:01 PM, JB wrote:
|
|
|
Powered by
FUDForum. Page generated in 0.04590 seconds