christopher.g.kennedy Posted January 13, 2016 Posted January 13, 2016 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.gifHow 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.
Ravi Kumar Posted January 14, 2016 Posted January 14, 2016 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 codewhile 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.
christopher.g.kennedy Posted January 14, 2016 Author Posted January 14, 2016 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-proimagesTo 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.pngDirectory 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]
Ravi Kumar Posted January 15, 2016 Posted January 15, 2016 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-mouse.png"]]></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:ImagesPenguins.jpg).and while uploading the report into Jasper server you need to change the Image Expressions as follows <imageExpression><![CDATA["repo:Penguins.jpg]]></imageExpressionwhile 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.
tdavincci Posted February 25, 2017 Posted February 25, 2017 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 studio2.jasper server3. 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 1change the datatype for your image to string,on the image field use this expression to decode the image backnew 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now