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.

1

sad Please Help sad

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's picture
Joined: Mar 18 2015 - 1:10pm
Last seen: 2 years 4 months ago

4 Answers:

0

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.

 

 

 

 

Ravi Kumar's picture
Joined: Aug 23 2014 - 8:08am
Last seen: 1 year 9 months ago
0

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:\Jaspersoft\jasperreports-server-6.2.0\apache-tomcat\webapps\jasperserver-pro\images

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:\Jaspersoft\jasperreports-server-6.2.0\apache-tomcat\webapps\jasperserver-pro\images     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:\Jaspersoft\jasperreports-server-6.2.0\apache-tomcat\webapps\jasperserver-pro>

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:\jaspersoft\jasperreports-server-6.2.0\apache-tomcat\{bin,conf,logs,webapps}

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

christopher.g.kennedy's picture
Joined: Mar 18 2015 - 1:10pm
Last seen: 2 years 4 months ago
0

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 

 

 

 

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-..."]]></imageExpression

 

 

 

 

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:\Images\Penguins.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.

 

 

 

 

 

 

Ravi Kumar's picture
Joined: Aug 23 2014 - 8:08am
Last seen: 1 year 9 months ago
0

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));
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()))
One year pass. lol. hope its still going to be helpful to you or others
tdavincci's picture
Joined: Jul 9 2016 - 9:16pm
Last seen: 1 year 6 months ago
Feedback
randomness