Jump to content

How do I add an image to a Jasper Report using studio 6.2 and make the image available in Jasper Server after uploading the report.


christopher.g.kennedy

Recommended Posts

http://community.jaspersoft.com/sites/all/libraries/ckeditor/plugins/smiley/images/sad_smile.gif Please Help http://community.jaspersoft.com/sites/all/libraries/ckeditor/plugins/smiley/images/sad_smile.gif

How do I add an image to a Jasper Report using studio 6.2 and make the image available in Jasper Server after uploading the report.

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

Hi , Select the Image Element from Palette, and drag and drop into Report , it will prompt a window "Create New Image Element",

it will list the Image Creation Mode, select the appropriate option,

if you find Browse option then select the image from the local or Remote file directory,

 

before uploading the Report to Jasper Server, you need to Replace the Image Path to "Repo:Image1.jpg" like this. in JRXML Source code

while uploading the Report it under resources section it will  list the Image name and then again you need to click on it and select the image from your machine repository.

 

 

 

 

Link to comment
Share on other sites

Hi Kumar, Thank you for responding.  I appreciate your solution.  Since I wanted to solve it last night, I selected a different method.  What I did was to create an image folder as: 

C:Jaspersoftjasperreports-server-6.2.0apache-tomcatwebappsjasperserver-proimages

To the folder, I added my image.  Then within studio, when I added the image from the design palette basic elements, I selected URL (a remote URL referring to an image, will be the expression value)

For the url, I enterred: http://localhost:8080/jasperserver-pro/images/DYSSeal.png

Directory of C:Jaspersoftjasperreports-server-6.2.0apache-tomcatwebappsjasperserver-proimages     01/13/2016  06:52 PM    <DIR>          .01/13/2016  06:52 PM    <DIR>          ..01/13/2016  05:47 PM            15,091 DYSSeal.png               1 File(s)         15,091 bytes               2 Dir(s)  310,665,125,888 bytes freeC:Jaspersoftjasperreports-server-6.2.0apache-tomcatwebappsjasperserver-pro>[/code]

In this way, I did not have to replace the image path with repo:... prior to uploading to jasper server, since the image is already in a server folder.  Additionally, I can use the same url for multiple reports.

My jrxml file looks as follows, localhost is c:jaspersoftjasperreports-server-6.2.0apache-tomcat{bin,conf,logs,webapps}

    <imageExpression><![CDATA["http://localhost:8080/jasperserver-pro/images/DYSSeal.png"]]></imageExpression>[/code]

 

 

Link to comment
Share on other sites

Hi Crystopher,

Check the ULR you have given in Address bar weather you are able to access the image or not ,

you cant access it because it is Server hosted URL, Pls observe below image test.PNG.a173255e7f5af4e2e1f3b08846fed888.PNG

 

 

 

if you want to access Remote Hosted Image you can use the URL in Image Expression as follows

 <imageExpression><![CDATA["http://www.mascotdesign.com/_dev/images/famous-cartoon-character-mickey-mouse.png"]]></imageExpression

Test2.PNG.277505ded6cc084ea1c8f588abf99c52.PNG

 

 

 

 

dont consider Jasper Server installed path is the Remote Server Path for Images/fiels.

 

if you want to Access Image from your local Machine then you need to Use your local Directory Path Eg: (C:ImagesPenguins.jpg).

and while uploading the report into Jasper server you need to change the Image Expressions as follows

   <imageExpression><![CDATA["repo:Penguins.jpg]]></imageExpression

while uploading the Report into Jasper server, under Controlls and Resources it will list out the name of the Image under Resources Section, Pls observe the below screen shot.

then again you need to add that image to Jasper server by clicking Add Now and browsing it from the local repository.

Test3.PNG.4da3ab2e5e3d79733cc2a64efed791a0.PNG

 

 

 

 

 

 

Link to comment
Share on other sites

  • 1 year later...

I once experianced difficulty with that, 

I have solved my problem in a different way. I used nusoap webservice as datasource for my project. That means I pass parameter to jasperserver then jasperserver will make a get request to a php page (or nusoap) where the parameters is used to get records from database. the record then returns in JSON format to jasperserver as datasource for the report.

after understanding this, you realize there are three stageshere.

1. jasper studio

2.jasper server

3. php page (nusoap), acting as datasource.

at stage 3.

you shoult encode the image using "base64_encode()"

/* just a dummy sample*/$sql = "SELECT name, image FROM ...";$result = $con>query($sql);    /* create one master array of the records */$records=array();if ($result->num_rows > 0) {while($row = $result->fetch_assoc()) {   $row['image']=base64_encode($row['image']); //encode Image   $records[] = array('myRows'=>$row);}//header('Content-type: application/json');return json_encode(array('records'=>$records));[/code]
then you echo back the result
 
at stage no 1
change the datatype for your image to string,
on the image field use this expression to decode the image back
new java.io.ByteArrayInputStream(org.apache.commons.codec.binary.Base64.decodeBase64($F{image}.getBytes()))[/code]
 
One year pass. lol. hope its still going to be helpful to you or others
 
 
 
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...