Page 1 of 1

JasperReportsPlugIn Problem with Image from Datafield

PostPosted: Wed Dec 19, 2018 2:21 pm
by wichmann
I try to implement a Image directly from mySQL Database (Media-Field) in Jasper Reports.

However, various attempts brought no success.

I think this should possible ... or not?
Is this a problm with my Software configuration?
Can anyone help

Installed Software:

Servoy 8.3.2
Jasper Studio 6.5.1
Barcode_Servoy_JasperReports_Plugin_v.6.4.1.7z.001
Barcode_Servoy_JasperReports_Plugin_v.6.4.1.7z.002

BR
Andreas

Re: JasperReportsPlugIn Problem with Image from Datafield

PostPosted: Thu Dec 20, 2018 9:40 am
by murmi
Hi Andreas

I use an Image Control and as an expression
$P{cMandLogo} != null ? net.sf.jasperreports.engine.util.JRImageLoader.loadImage((byte[])$P{cMandLogo}) : null

cMandLogo is passed to the report engine as Parameter, which is nothing more as the content of a database field. Instead of $P{param} you should be able to use $F{Field}.

HTH
Fritz

Re: JasperReportsPlugIn Problem with Image from Datafield

PostPosted: Fri Dec 21, 2018 4:40 pm
by Gabi Boros
here is an example that may help:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.4.0.final using JasperReports Library version 6.4.1 -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xs ... report.xsd" name="f_products" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="96b8fd89-386b-483b-9a1f-4df248f4f63f">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="UDM.xml"/>
<property name="com.jaspersoft.studio.data.sql.tables" value=""/>
<queryString>
<![CDATA[]]>
</queryString>
<field name="product_image" class="java.lang.Object"/>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="199" splitType="Stretch">
<image>
<reportElement x="0" y="10" width="150" height="150" uuid="1e283262-ea36-461c-8484-d82cc0b6178d"/>
<imageExpression class="java.awt.Image"><![CDATA[net.sf.jasperreports.engine.util.JRImageLoader.getInstance(DefaultJasperReportsContext.getInstance()).loadAwtImageFromBytes((byte[])$F{product_image})]]></imageExpression>
</image>
</band>
</detail>
</jasperReport>