Users can store image files into JasperReports Server (JRS) repository database, and use a query to get the image resource and have the image blob displayed in the report.
Here is a very simple sample report to demonstrate how to display a repo image in a report. Users need to deploy the "st_patricks_day.gif" image into the JRS repository in any folder (make sure the image label is st_patricks_day.gif) and test run the report in JSS 7.9 using that repo datasource.
- report query
select f.data from jifileresource f inner join jiresource r on r.id = f.id and r.label = 'st-patricks-day.gif'
- field type
<field name="data" class="java.io.InputStream"/>
- display the image field in the report
<image> <reportElement x="0" y="0" width="572" height="180" uuid="f3d25d1b-8cf2-4c1f-ab6b-8269afaf0a6f"/> <imageExpression><![CDATA[$F{data}]]></imageExpression> </image>
Report Template
<?xml version="1.0" encoding="UTF-8"?> <!-- Created with Jaspersoft Studio version 7.9.0.final using JasperReports Library version 6.16.0-48579d909b7943b64690c65c71e07e0b80981928 --> <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/xsd/jasperreport.xsd" name="sample report" language="groovy" pageWidth="612" pageHeight="792" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="e0793667-0723-42e3-be12-37c9ec18aae9"> <property name="ireport.zoom" value="1.0"/> <property name="ireport.x" value="0"/> <property name="ireport.y" value="0"/> <property name="com.jaspersoft.studio.data.defaultdataadapter" value="JRSrepo"/> <queryString> <![CDATA[select f.data from jifileresource f inner join jiresource r on r.id = f.id and r.label = 'st-patricks-day.gif']]> </queryString> <field name="data" class="java.io.InputStream"/> <background> <band splitType="Stretch"/> </background> <title> <band splitType="Stretch"/> </title> <pageHeader> <band splitType="Stretch"/> </pageHeader> <columnHeader> <band splitType="Stretch"/> </columnHeader> <detail> <band splitType="Stretch"/> </detail> <columnFooter> <band splitType="Stretch"/> </columnFooter> <pageFooter> <band splitType="Stretch"/> </pageFooter> <summary> <band height="200" splitType="Stretch"> <property name="com.jaspersoft.studio.unit.height" value="px"/> <image> <reportElement x="0" y="0" width="572" height="180" uuid="f3d25d1b-8cf2-4c1f-ab6b-8269afaf0a6f"/> <imageExpression><![CDATA[$F{data}]]></imageExpression> </image> </band> </summary> </jasperReport>
Report HTML output showing the gif animation
==================================================
TTC-20210515
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now