I am using jasper reports and ireport to desing the report. The report is having a jpg image. I am giving the relative path to image in 'image expresion' field of ireport i.e "/client/resource/image/playUp.jpg"
The report is exported to differnet format(PDF, XLS, RTF) using web application i.e using jasper report API
The problem is that image is not getting rendered in PDF, XLS and RTF format. For HTML it is working fine.
The relative path starts from web application root.
How can i get images in pdf, xls, and rtf format providing the relative path .
Is there any way to embedd the image in pdf, xls, and rtf format.
Post edited by: aditya_gupta, at: 2007/06/27 09:31
It is still dont work . Do you have any other solution.
Attached is the jrxml file for your reference.
Aditya [file name=VoiceSession-7e037689d9c580f31f40d4a60a126ca0.jrxml size=34115]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/Voi...
I attached 2 ziped files (with improved path within image). Look on image paths I proposed (and correct if it needs). In my templates this solution works.
Michael W. [file name=try_this.zip size=6508]http://www.jasperforge.org/components/com_joomlaboard/uploaded/files/try...
Thanks for your reply. I have checked the both jrxml files,it is not working.
I have already tried with two backslashes but the image didnt appear.
Any other solution. I am totally in no where land.
Do you require any other file or code snippet? please let me know.
I think that you have to check where your template and where your direcory with "playUp.jpg" image are situated. Maybe it is the problem. For example:
image localization: C:/resource/image/playUp.jpg (sorry, slash doesn't work on forum)
template localization: C:/template.jrxml
Open template.jrxml by iReport 2.0. In this case you should set path of image in template: "/resource/image/playUp.jpg" (remember: write two backslashes instead one of course). If path is OK then iReport automatically shows image content.
Example for web application which is deployed by NetBeans:
Post edited by: wiciu, at: 2007/07/06 09:52
Post edited by: wiciu, at: 2007/07/06 09:55
First let you know that I am using jasper file in web appliaction and I have checked the path of both (image and jasper file). It is fine.
The image is coming when I am providing the relative path in ireport 1.3.0 but when I run the template in ireport as a pdf , the image is displayed in pdf because I have set the classpath of iReport to the image directory.
But when I am using this compiled template file(jasper file) in web application, the image is not there in pdf,rtf and xls format.
I am using the same method for template which have scriptlets jar file. i.e. Adding path of jar file to ireport classpath and my template file is another path.
So in web application i just add jar files as a library and use that jasper file. Its working fine there but for images it is not working.
For example, the path for template and image which is used in web application(using netbeans) is,
Template jasper path:
I think the problem lies only with the path.
Do you know how to contact Tedord, forum administrator. He may solve this issue.
Post edited by: aditya_gupta, at: 2007/07/06 12:46
I think similarly that the problem lies with the path. In web applications "web" is like a "root direcory" so maybe you should set path to image like this:
Hm, I don't know how to contact Tedord.
Post edited by: wiciu, at: 2007/07/06 13:13
I think you first need to understand how JasperReports exporters work with images, especially if they are "lazy-loaded" images (see the isLazy image flag).
I would only say that when you specify an image source using its relative URL within your current Web applications, you should expect it to work only when viewed in HTML format from within that Web application only.
Imagine you have a HTML file on your machine that loads an image from your local file system. And then you give that HTML to somebody else who does not have that image on their computers. How would you expect them to see the image, if the relative URL will not work on their machines?
A similar thing happens in this case you described here.
The PDF export process within your Web application, does not know anything about the Web context in which it is being executed. It cannot understand that those are relative URLs. Relative to what??...
If only you would have put complete URL locations for the images, something like http://www.mycompany.com/myapp/myfirstimage.jpg, the PDF export process would be able to load the images from their public location and embed them into PDF.
You could provide complete URL locations for the images by extracting them from the current application servlet context like this:
See this for more details:
Of course, you would need to pass the servlet context as a parameter to the report.
I hope this helps.
> the servlet context as a parameter
> to the report.
How do you pass it as a parameter when the report is running in JasperServer?
I tried setting up a parameter in the jrxml by importing javax.servlet.* and setting the parameter as type javax.servlet.ServletContext with value getServletConfig().getServletContext(), but that didn't seem to work. I tried a couple variations too. Am I in the right direction?
I have similar issue with paths to subreports not being found unless i do absolute url path, but this seems not good for long term.
I saw you can get servercontext/full path to item and pass as parameter to main jrxml file, but then the users who use just ireports instead of web app i think might have a problem as they are looking at jrxml files and not java app which would feed necessary subreport urls.
I have used iReport 3.5.2, but I still cannot pass relative path for showing image.
I have created an image field with expression class "java.io.File" and the image expression as "new java.io.File("logo.gif")".
The windows classpath and classpath in iReport are also set but it still cannot work.
Can anyone tell me how can I make it work?
Post Edited by nykkit at 07/14/2009 10:39
Use the below expression in the image Expression of jasper report IDE on image properties of the jrxml and the relative image path
Satish M Hiremath