India

ZestyBeanz Technologies Pvt Ltd 4th Floor, Nila, Technopark Thiruvananthapuram,
India – 695581
Phone: +91 471 4063254
Fax : +91 471 2700171

   .

ZestyBeanz Technologies Pvt Ltd
61/3236, Manikkath Cross Road
Ravipuram, Kochi, India - 682016
Phone: +91 484 4063254

  UAE

Zesty Labs
Office # 2003, Millennium Plaza Building
Sheikh Zayed Rd, Dubai, UAE
Phone: +971 4333 2222​
Mobile: +971-52-7553466

  Germany​

ZestyBeanz Technologies GmbH
Reuterstraße 1
90408 Nürnberg
Fon: +49 911 4801 444
Fax: +49 911 4801 445

Contact Form


Prajul P T's picture

Dynamic Image From Database in Jasper Report

   When dealing with internal documentation in a company, images plays an important role. For example, company logo is a must in most of the documentation in a company. Here I am going to explain how to create dynamic images in jasper report fetched from the database.

   I am using iReport 4.7.1 with OpenERP. In my report I am passing the image to the report as a parameter. I have created a parameter in iReport as "logo" which holds image data passed from the python to the report. In python side, i am fetching my logo as: 

and passed to report as a parameter "logo". The variable class of logo should be  "java.lang.String".

   In report add a Report Import directive "org.apache.commons.codec.binary.Base64". To do that in iReport, right click on the report and go to "Properties" at the end you can see "Imports" as shown below:

Add the entry to it. Now create a variable say "photo"  with "Variable class" as "java.io.InputStream", "Calculation" as "Nothing", "Reset Type" as "Report" and "Variable Expression" as:

new ByteArrayInputStream(new Base64().decodeBase64($P{logo}.getBytes("UTF-8")))

where $P{logo} is the parameter created earlier which contain image data.

   Now drag and drop the image component from the pellet window. When the windows prompt to select the image, press cancel. Now in "Image Expression" field, add the variable $V{photo} created before and "Expression Class" as "java.io.InputStream". If you are intending to put the logo in title band, set evaluation time to "Report". Now the report should be printed with logo from the database.

Reply

The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <c>, <cpp>, <drupal5>, <drupal6>, <java>, <javascript>, <php>, <python>, <ruby>. The supported tag styles are: <foo>, [foo], [[foo]]. PHP source code can also be enclosed in <?php ... ?> or <% ... %>.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.