How to show an image in iReports using a foundset

Find out how to get things done with Servoy. Post how YOU get things done with Servoy

How to show an image in iReports using a foundset

Postby gerardo.gomez » Mon Jan 11, 2010 12:46 pm

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...
Attachments
image_in_report_foundset.JPG
iReport with image from temp file...
image_in_report_foundset.JPG (106.69 KiB) Viewed 29697 times
Best regards/Un saludo,

Gerardo Gómez
--
Servoy 5.1.4 build 964
Win7 - Java 1.6.0_20
Ubuntu 10.04 - Java 1.6.0_20
gerardo.gomez
 
Posts: 79
Joined: Thu Aug 20, 2009 1:15 am

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

Postby david » Mon Jan 11, 2010 8:40 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

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

Postby gerardo.gomez » Mon Jan 11, 2010 10:40 pm

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.
Best regards/Un saludo,

Gerardo Gómez
--
Servoy 5.1.4 build 964
Win7 - Java 1.6.0_20
Ubuntu 10.04 - Java 1.6.0_20
gerardo.gomez
 
Posts: 79
Joined: Thu Aug 20, 2009 1:15 am

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

Postby jmeunier » Mon Jan 11, 2010 11:13 pm

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
Jason Meunier
Servoy USA
jmeunier
 
Posts: 79
Joined: Tue Jan 24, 2006 11:19 pm
Location: Thousand Oaks, CA

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

Postby david » Tue Jan 12, 2010 12:34 am

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}")
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

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

Postby david » Tue Jan 12, 2010 1:57 am

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})
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

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

Postby rgansevles » Tue Jan 12, 2010 4:19 pm

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
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1927
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

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

Postby david » Tue Jan 12, 2010 9:59 pm

How about a dedicated Jasper section on the Servoy forum? Google groups is just one more place to monitor for questions and responses.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

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

Postby pbakker » Wed Jan 13, 2010 10:38 am

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
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

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

Postby lwjwillemsen » Wed Jan 13, 2010 11:30 am

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 !
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 680
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

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

Postby Harjo » Wed Jan 13, 2010 12:04 pm

I agree, the plugin is soo related to Servoy, why not a separate dedicated Jasper section here?
Harjo Kompagnie
ServoyCamp
Servoy Certified Developer
Servoy Valued Professional
SAN Developer
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

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

Postby david » Wed Jan 13, 2010 6:04 pm

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.
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

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

Postby gerardo.gomez » Wed Jan 13, 2010 9:44 pm

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.
Best regards/Un saludo,

Gerardo Gómez
--
Servoy 5.1.4 build 964
Win7 - Java 1.6.0_20
Ubuntu 10.04 - Java 1.6.0_20
gerardo.gomez
 
Posts: 79
Joined: Thu Aug 20, 2009 1:15 am

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

Postby pbakker » Thu Jan 14, 2010 10:42 am

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
pbakker
 
Posts: 2822
Joined: Wed Oct 01, 2003 8:12 pm
Location: Amsterdam, the Netherlands

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

Postby chourasia.sheetal02 » Thu Oct 04, 2012 1:17 pm

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
chourasia.sheetal02
 
Posts: 2
Joined: Wed May 16, 2012 3:23 pm

Next

Return to How To

Who is online

Users browsing this forum: No registered users and 7 guests