JDGuide
JDGuide

Reputation: 6525

JasperReports: PDF generation with image from database

I want generate PDF File with an image. The image name from database and physically the image is present inside local drive or remote server. I want to pass image name to the PDF.

Currently I am doing this by put an image element inside the iReport IDE designer and pass the server path or local drive path to that image.

It works fine. But I need some other type for dynamic images.

Upvotes: 1

Views: 2465

Answers (1)

Raffaele
Raffaele

Reputation: 20885

If the image can be reached by the app with a URL you can add a paramter named IMAGE_SRC, and specify in the iReport designer

image expression: new java.net.URL($P{IMAGE_SRC})
expression class: java.net.URL

for the image. Then at runtime you will fill the report after setting the parameter IMAGE_SRC with the value readed from the database

Upvotes: 2

Related Questions