Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Jasper Reports - Embedding Images

Table of Contents

About embedding images


Convert your image to Base64
Adding a Base64 image into iReport
Set the image in iReport
URLs

About embedding images

In order to include images into Emprise Jasper Reports, the images need to be converted into Base64 images

One downside of this process is that iReport has a limit of 65535 unicode characters for an image, so any image used must be relatively small and
optimized. I recommend sticking to logos only.

Convert your image to Base64

1. Create your image and make it a .gif


2. Go to this URL and choose upload image
3. Choose your file
4. Choose encode your image

In the Copy Code page, copy the Base64 String. To find out if the image string is 65535 or less, you can get a character count of the string by going to
this URL

Adding a Base64 image into iReport

1. In iReport, right click on the Variables node in the Report Inspector tree
2. Choose Add Variable
3. In the Properties panel, add IMAGE_BYTES to the name property
4. The Variable Class should be of type java.lang.String
5. Add the base64 code string to the Initial Value Expression with the code inside double quotes
6. Set the Reset Type to Page

Set the image in iReport

To add the image into your report:

1. Click on window menu and then palette to launch the palette panel
2. Selec the image element and Drag a new image element to your iReport band and
3. iReport will prompt you to locate the image > choose Cancel
4. Select the image in iReport and in the Image Expression field, add
new java.io.StringBufferInputStream( new org.w3c.tools.codec.Base64Decoder($V{IMAGE_BYTES}).processString() )
5. Make sure the Expression class is java.lang.String
6. Scale Image should be Retain Shape

URLs

How to embedd and SVG image in iReport


Tip: embedding images in reports
Embedding image in JRXML template
Base64 images from xml datasource
JasperReports XML Datasource with Inline Images
JasperReports: image expression url
JasperReport from XML Datasource with Inline Images

You might also like