This post is help full for integration dynamic image at jasper when your image data in blob or longblob in database.
there is following step to get your desire output:
Step-1: Make your field in Jasper through palette:
Name:logo
field Class: java.lang.object
Step-2: Drop image box from palette and provide properties as:
Image Expression : net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{logo})
Expression Class java.awt.Image
Step-3: Java variable
set logo as java.lang.Object datatype and set image data (byte[]) in logo variable .
private Object logo;
Example:
Java Code:
public class DemoJasperData{
private Object logo;
public Object getLogo() {
return logo;
}
public void setLogo(byte[] yourImagebyteData) {
this.logo = yourImagebyteData;
}
}
.jrxml :
<field name="logo" class="java.lang.Object"/>
<image scaleImage="FillFrame">
<reportElement x="9" y="8" width="100" height="98" uuid="053b21f7-00a3-4387-a6b3-c33475287f4c"/>
<imageExpression><![CDATA[net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{logo})]]></imageExpression>
</image>
Now your dynamic image is ready on jesper Report
there is following step to get your desire output:
Step-1: Make your field in Jasper through palette:
Name:logo
field Class: java.lang.object
Step-2: Drop image box from palette and provide properties as:
Image Expression : net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{logo})
Expression Class java.awt.Image
Step-3: Java variable
set logo as java.lang.Object datatype and set image data (byte[]) in logo variable .
private Object logo;
Example:
Java Code:
public class DemoJasperData{
private Object logo;
public Object getLogo() {
return logo;
}
public void setLogo(byte[] yourImagebyteData) {
this.logo = yourImagebyteData;
}
}
.jrxml :
<field name="logo" class="java.lang.Object"/>
<image scaleImage="FillFrame">
<reportElement x="9" y="8" width="100" height="98" uuid="053b21f7-00a3-4387-a6b3-c33475287f4c"/>
<imageExpression><![CDATA[net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$F{logo})]]></imageExpression>
</image>
Now your dynamic image is ready on jesper Report