Jasper report image paths

2019-02-24 22:10发布

I want to insert images in my jasper report ,swing application. All images are in one package. I want to set path for images in jasper report.That means, to set project images's paths.When the entire project location is changed, there is an exception saying no images found. Please let me know how to set the image paths.

Project structure: MyProject
|-Source Packages

under source package
|-Images // my images are in here
|-Reports // where my jasper reports are in
|-MyJFrames |

2条回答
虎瘦雄心在
2楼-- · 2019-02-24 22:54

You haven't posted many particulars, but i have ran into a similar issue when dealing with absolute/relative paths with Jasper Report.

There is a known "discomfort" or a bug (if you want to call it that way) with Jasper Report not being able to set or use relative paths to your project resources (subreports, images etc) especially if you are compiling the reports with the IREPORT designer tool.

I am working with jasper report and IREPORT 4.1.1 and every time i compile the JRXML to a .jasper file, my paths are absolute. This causes "havoc" when the whole project is moved to a different machine. In order to use relative paths to my reports i have to compile the reports via programming means i.e in my Java application. In a nutshell, the java utility method i am using reads the JRXML file and substitutes the absolute path with a relative path and then compiles the report.

Take a look at this forum, which has some different answers of how to do it.

http://forums.devshed.com/java-help-9/relative-path-for-subreport-in-jasperreport-309313.html

查看更多
姐就是有狂的资本
3楼-- · 2019-02-24 23:06

I also faced the same problem as you. To solve this, use a hard coded path value. You have to create one parameter to which you can pass your image location and then use this parameter in your image expression. I found solution in this post.

查看更多
登录 后发表回答