0

Currently I am working on iReport, using MySql DB.

I am saving the image as a String id using servlet, not exactly the image name (like helal.JPG). But i cannot rendered this as a image on iReport.

Can anyone please help?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Helal Uddin
  • 1
  • 1
  • 1

1 Answers1

0

For image 200 x 300 use <imageExpression> with String parameter.

E.g.

<parameter name="IMG_PATH" class="java.lang.String"></parameter>

...

<image ...>
    <reportElement x="0" y="0" width="200" height="300"/>
    <imageExpression class="java.lang.String">
        <![CDATA[$P{IMG_PATH}]]>
    </imageExpression>
</image>

See also http://jasperreports.sourceforge.net/sample.reference/images/index.html

Michal
  • 611
  • 5
  • 11
  • So basically here you need to query the database for image path. – Michal Sep 09 '13 at 10:46
  • hi Michal,Thanks for your reply, but it does not work. i am using this ` <![CDATA[$F{employeeSignature}]]> ` – Helal Uddin Sep 09 '13 at 11:01
  • here employeeSignature is my image value, which saved in DB as a Id like 4028b21240c34f360140c352f84e0004 – Helal Uddin Sep 09 '13 at 11:11
  • I am using Oracle but i have to make the image a **java.io.InputStream** to make this work – Mike Noland Sep 09 '13 at 14:46
  • Did you try to adjust imageExpression's class e.g. `` ... (or whichever "class" is suitable)? – Michal Sep 09 '13 at 14:52
  • hi Michal, I have already used this, also used java.awt.Image class – Helal Uddin Sep 10 '13 at 09:13
  • What is the type of image? The above should work for JPG, PNG, GIF. Is it any different? – Michal Sep 10 '13 at 09:16
  • Maybe try this http://stackoverflow.com/questions/15833031/jaspersoft-studio-report-how-to-insert-images-from-database or http://community.jaspersoft.com/questions/514052/showing-image-database – Michal Sep 10 '13 at 09:26
  • hi MikeNoland and Michal, i think u guess my image is stored on DB as image format(like imageName.JPG, PNG etc), but it stored on My DB as a String id and i m trying to rendered it by query that concat with servletRepository+id – Helal Uddin Sep 10 '13 at 10:20
  • Options are: 1. store image as BLOB, 2. introduce server call to actually return image (based on given string id). What is your structure of the images table? – Michal Sep 10 '13 at 14:31