Page 1 of 2

How to show an image in iReports using a foundset

PostPosted: Mon Jan 11, 2010 12:46 pm
by gerardo.gomez
Hi everybody!!!

I'm creating a report using foundsets from Servoy, but I have a problem with images... Well, the images aren't showed in the report...

I had tried it showing the image as several field class in iReports, but I didn't get nothing...

Anybody knows what field class I need to show the images? Anybody can help me with this? (Perhaps I must to post it in jasperreports site issues...)

Thanks in advance!!!

Best regards,

Gerardo.

P.S.: by now, I need only an image in report header (the company logo in a invoice), due to this, I have a tricky workaround: I'm creating a temp file and I'm showing that file in report from full path to that temp file...

Code: Select all
   
        // ...
   // Creates a temp file (using Servoy file plugin) with logo (media data) from my companies table
   // and returns full path to that file:
   var pd_logo = getImagePath(_to_empresas_saas_company.logo);
   
   // ...
   // attach the full path to params object:
   params.p_logotipo = pd_logo;

   // ...
   // just call jasper reports plugin:
   plugins.jasperPluginRMI.runReport(foundset, reportName, false, 'view', params);


The report...

Re: How to show an image in iReports using a foundset

PostPosted: Mon Jan 11, 2010 8:40 pm
by david
We store static images in Servoy's web server: "/Applications/Servoy/application_server/server/webapps/ROOT/image_directory". You can reference these images using an image expression in Jasper that specifies the URL to the image (ie: (String) "http://localhost:8080/image_directory/image_name.jpg").

You can abstract this a bit so that the server URL is not hard coded into the report:

1- create a string parameter ("serverURL" in this example) with a default expression of "http://localhost:8080"
2- change the image expression to include the server URL parameter: "$P{serverURL} + "/image_directory/image_name.jpg"
3- pass the server URL to the report when calling from Servoy

This will show your images from within iReport while developing and from Servoy when deployed.

Re: How to show an image in iReports using a foundset

PostPosted: Mon Jan 11, 2010 10:40 pm
by gerardo.gomez
Hi David!

Thanks for your answer!

But in my case, the image is not static, I'm loading the company logo from a table of companies data (in the solution, with a Saas enviroment, an admin user can select and load a logo for his company in a form with his companies data). That way, creating the temp file with the database data, I can show that logo with the full path (my strategy in this point looks like yours).

With this workaround I can solve the logo image (it's only one image for each invoice), but if I want to generate a report with a list of products or employees cards, that strategy does't look very proper... (creating a temp file for the image of each employee or product is not a very interesting strategy, don't you think?)

Best regards,

Gerardo.

Re: How to show an image in iReports using a foundset

PostPosted: Mon Jan 11, 2010 11:13 pm
by jmeunier
This is better answered in the google group forum. I will post an answer there:

http://groups.google.com/group/servoy-j ... rts-plugin

Jason

Re: How to show an image in iReports using a foundset

PostPosted: Tue Jan 12, 2010 12:34 am
by david
For dynamic images, you can use the InputStream type. Steps:

1- create your report query, containing the byte or other blob fields. click "read the fields" so jasper knows what fields are in the query.
2- now in the library, right-click a blob field and select "edit". change the field class type to "java.io.InputStream".
3- now place an image on your report (not a field!). select its properties and change the image expression class to "java.io.InputStream"
4- still in the image properties, enter the blob field in the image expression without quotes (ie: $F{blob_name}, not "$F{blob_name}")

Re: How to show an image in iReports using a foundset

PostPosted: Tue Jan 12, 2010 1:57 am
by david
jmeunier wrote:I will post an answer there:

http://groups.google.com/group/servoy-j ... rts-plugin


Building on Jason's method (thanks for the awt code!), you can send an image as a parameter as well. For graphics that don't differentiate based on record row -- such as your header graphic case -- this would be appropriate.

1- create a parameter in jasper of type "java.awt.Image" (called "header_graphic" in this example)
2- place an image on your report. select its properties and change the image expression class to "java.awt.Image"
3. still in the image properties, enter the parameter name in the image expression without quotes (ie: $P{header_graphic})
4. send a java.awt.Image over from the Servoy method calling the report. how you find the record with the correct image i have left out:

Code: Select all
var image = new Packages.java.io.ByteArrayInputStream(insert_record_blob_field_here)
var image_awt = Packages.javax.imageio.ImageIO.read(image)
plugins.jasperPluginRMI.runReport(controller.getServerName(),'image_test.jrxml',null,'view',{header_graphic: image_awt})

Re: How to show an image in iReports using a foundset

PostPosted: Tue Jan 12, 2010 4:19 pm
by rgansevles
jmeunier wrote:This is better answered in the google group forum. I will post an answer there:

http://groups.google.com/group/servoy-j ... rts-plugin

Jason


I agree,

Rob

Re: How to show an image in iReports using a foundset

PostPosted: Tue Jan 12, 2010 9:59 pm
by david
How about a dedicated Jasper section on the Servoy forum? Google groups is just one more place to monitor for questions and responses.

Re: How to show an image in iReports using a foundset

PostPosted: Wed Jan 13, 2010 10:38 am
by pbakker
How about a dedicated Jasper section on the Servoy forum? Google groups is just one more place to monitor for questions and responses.


Better to just have all servoy_jasperreports plugin related stuff in one place, so please post all questions, suggestions etc. on there.

Paul

Re: How to show an image in iReports using a foundset

PostPosted: Wed Jan 13, 2010 11:30 am
by lwjwillemsen
Hi Paul,

I agree, but it would be (very) nice if the google servoy-jasper-group messages are automatically pushed to a (read only) Jasper section on the Servoy forum...

That way I don't have to monitor both sites...

I use the rss feed of the servoy forum by the hour and I am very pleased with it !

Re: How to show an image in iReports using a foundset

PostPosted: Wed Jan 13, 2010 12:04 pm
by Harjo
I agree, the plugin is soo related to Servoy, why not a separate dedicated Jasper section here?

Re: How to show an image in iReports using a foundset

PostPosted: Wed Jan 13, 2010 6:04 pm
by david
Another advantage of having a separate section here: way more people will see the information. Including all new Servoy developers coming online who may have no idea about the jasper plugin to begin with.

Re: How to show an image in iReports using a foundset

PostPosted: Wed Jan 13, 2010 9:44 pm
by gerardo.gomez
Hi everybody!

I'm agree with posting doubts and solutions about jasperReports plugin/Servoy in the both sites... Perhaps lwjwillemsen's idea it's a good tip for do it...

Whatever, I post other way for showing images in iReports using a foundset: http://groups.google.com/group/servoy-jasperreports-plugin/browse_thread/thread/e3154efed4e06197/0f5ae4901fb87208#0f5ae4901fb87208

Best regards,

Gerardo.

Re: How to show an image in iReports using a foundset

PostPosted: Thu Jan 14, 2010 10:42 am
by pbakker
An easy way to monitor forums are RSS feeds. The Servoy forum supports those as well as Google Groups.

So, just add the RSS feed of the google group for the servoy_jasperreports plugin to your RSS reader and you're done.

All servoy_jasperreports plugin related questions, issues etc. are to be posted on the Google group and that will not change.

Paul

Re: How to show an image in iReports using a foundset

PostPosted: Thu Oct 04, 2012 1:17 pm
by chourasia.sheetal02
Hi all,
I am little new to servoy, I want to display photo on jasper report(report runs dynamically), photos are placed on the server, when the report is run from (after downloading from the server on different m/c ) smart client, the report appears but the photo is missing so is there any way to display photo / image on the jasper report. How can I display photos on ireport?

It will be great if any one can provide me solution as soon as possible.

Sheetal