Dynamic images on the Jasper Report Detail Band or Table
To generate dynamic images on the Jasper Report Detail Band or Table, follow these steps:
Step 1:
Create an Image field for uploading dynamic images.
Step 2:
Write the SQL in the Jasper Report Query Editor to get the image’s logo path.
Example:
SELECT (SELECT b.column40545 FROM Table1924 AS b LIMIT 1) || 'uploads' || current_database() || '/Folder403/' || a.id || 'column36680.gif' FROM Table403 AS a WHERE a.column4885 = 'ELECAB0020';
Explanation of the SQL:
-
(SELECT b.column40545 FROM Table1924 AS b LIMIT 1)
→ Retrieves the cloud URL. -
'uploads'
→ Default value for accessing the upload folder of the image. -
current_database()
→ Retrieves the name of the currently accessed cloud. -
'/Folder403/'
→ Folder name corresponding to the table ID. -
a.id
→ Record ID. -
'column36680.gif'
→ Image field ID. -
Table403
→ The table from which the image path is taken. -
a.column4885 = 'ELECAB0020'
→ Condition to filter specific line item records.
Step 3:
Create a field for the image path in the Query Editor or Dataset (field type should be String).
Step 4:
Create an Image component on the Detail Band or Table, with the expression:
com.itaakash.View.HelperFunctions.getcustomimagepath($P{cloudcode}, $F{itemcode1})
-
$P{cloudcode}
→ Retrieves the cloud code. -
$F{itemcode1}
→ Image path field created in the previous step.
When these steps are followed, you will be able to display dynamic images in the Detail Band or Table using parameters.