Monday, December 10, 2007

BIRT: Dynamic Images

There was a question on the BIRT newsgroup about how to put a dynamic image into a report file. This is typically done in multi-company sites, where a different header or logo will appear based on some environmental parameter. In the following example I will show how to do this with a report parameter, although the same thing can be done based on a URL.

The following example will show one of two logos, depending on the value of a report parameter. If the value is equal to 0, we will show the Eclipse logo at

If the value is 1, we will show the BIRT Exchange logo:

This image will reside in the Master Page of the report. So lets take a look at how to do this.

  1. First, create a new report called DynamicImage.rptDesign

Figure 1. Create new Report

  1. In the new report design, open up the Master Page tab.
  2. Drag over a grid, and make it 2 column, 1 row.
  3. In the 1st column, drag over an Image component.
  4. For the URL, put in “”. Be sure to keep the quotes. This is more as a place holder than anything else.

Figure 2. Master Page with Image

  1. Create a new report parameter called imageSelector. It needs to be an Integer type. In the following screen shot, I am using a List Box and a List of Values for this purpose.

Figure 3. Create new Parameter

  1. Select the Image.
  2. Open the Script tab in the Report Designer
  3. Change the Event to onRender.
  4. Use the following BIRT Script
if (params["imageSelector"] == 0)

  1. Save and run.

When you set the value to Eclipse, it will show the Eclipse logo. When set to the BIRT Exchange, it will show that logo.

Figure 4. The Final Report


Anonymous said...

that was alomst exactly was i was looking for. thx a lot.

i will have to choose a uri based on a value in my dataSet, so i need to access the dataSet from the script.. hope to find an example.

Jassi said...

how we can change image name dynamically for dynamic image

Anonymous said...


Embedded images with birt 4.2.2 viewer are not working , we are using weblogic 11 , oracle 11g
Our application is deployed in weblogic 11 and when trying to view the old reports the images which are embedded in the rpt design is not getting displayed

Unknown said...

Hi this example is perfect, but, how can I put the URL if I get it in the data set depending on an input parameter??

kareppa said...

i have one image folder it containing 300 images,(i have image url in csv file), using that image url ,i need to display in birt report,plz help me