Jump to content

Sub-report: Image from InputStream


diego_scunha

Recommended Posts

Hi,

Im using JasperReports 3.7.6 and iReport in my Desktop application. I have the following kind of report:

report-1 (text data)
 - sub-report-1 (with image)
 
The problem is that I have the image byte array on memory on my app. I would like to interact with Jasper in order to resolve the file location by myself. I mean when Jasper going to try to get the image (img-1.jpg, img-2.jpg, img-n.jpg) I would like to get the image by my Java code and return its input stream.

This is beacause images are saved in a storage and they are encodded by an specific algorithm. This is why I need to resolve image by name and return it to the Jasper in order to fill the report.

Is there some filter or interceptor?

Best regards.

Link to comment
Share on other sites

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

 

You just need to create an InputStream parameter in the master and then in the subreport and make sure you pass the value of that parameter from the master to the subreport using the <subreportParameter> tag. You then use the parameter in the image expression inside the image.

I suspect you do not make the parameter value pass from the master to the subreport. If you do, then attach here the relevant JRXMLs so that we can see for ourselves.

 

I hope this helps.
Teodor

 

Link to comment
Share on other sites

Hi all! I've solved this thread:

I created a helper java class with a method that decodes the images and then returns its as an InputStream. After that, I exported it as an jar and added to the iReport classpath.

After all I created an image object with "Image Expression" property calling my method from my helper class.

Thanks everbody for helping me,

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...