Home
Analytics
Images in relative path are not shown
locutuz
Hello everybody,
I have a problem with rendering an HTML report that includes images in a relative subfolder.
Let me describe my situation:
In the BIRT designer I created a .rptdesign file that references an image file in the shared resources.
In my report-design project, I created a subfolder "res" where I put all the images that are referenced
by the report.
In my application, a report shall be created based on that rptdesign.
So I wrote a "ReportGenerator"-plugin that creates a HTMLRenderOption-object for the RunAndRenderTask.
When I run the application, everything works fine (the HTML report is generated) but without the images.
An exception in thrown, saying "image source res/myImage.png is not found!"
even though the images are under the subfolder "res" of my Generator plugin.
The images are even not copied to the directory I specified in HTMLRenderOption.setImageDirectory().
Below is an extract of the stack trace. It seems that the report engine cannot get the image stream.
Probably I have to set something like a "prefix" to say the reportEngine "Look in the <prefix> folder for images".
Does anybody have the same problem and can help me?
Thanks in advance.
Regards,
Sebastian
SCHWERWIEGEND: res\myImage.png (Das System kann den angegebenen Pfad nicht finden)
java.io.FileNotFoundException: res\myImage.png (Das System kann den angegebenen Pfad nicht finden)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(FileInputStream.java:120)
at org.eclipse.birt.report.engine.api.impl.Image.getImageStream(Image.java:245)
at org.eclipse.birt.report.engine.api.impl.Image.writeImage(Image.java:313)
at org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler.saveImage(HTMLCompleteImageHandler.java:230)
at org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler.handleImage(HTMLCompleteImageHandler.java:202)
at org.eclipse.birt.report.engine.api.HTMLCompleteImageHandler.onFileImage(HTMLCompleteImageHandler.java:136)
at org.eclipse.birt.report.engine.api.HTMLImageHandler.onFileImage(HTMLImageHandler.java:70)
at org.eclipse.birt.report.engine.emitter.html.HTMLReportEmitter.getImageURI(HTMLReportEmitter.java:3189)
at org.eclipse.birt.report.engine.emitter.html.HTMLReportEmitter.startImage(HTMLReportEmitter.java:2948)
at org.eclipse.birt.report.engine.emitter.CompositeContentEmitter.startImage(CompositeContentEmitter.java:274)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:74)
at org.eclipse.birt.report.engine.layout.html.HTMLTableLayoutEmitter.startContent(HTMLTableLayoutEmitter.java:146)
at org.eclipse.birt.report.engine.emitter.ContentEmitterAdapter.startImage(ContentEmitterAdapter.java:174)
at org.eclipse.birt.report.engine.emitter.ContentEmitterUtil.startContent(ContentEmitterUtil.java:74)
at org.eclipse.birt.report.engine.layout.html.HTMLTableLayoutEmitter.startContent(HTMLTableLayoutEmitter.java:146)
Find more posts tagged with
Comments
mwilliams
Have you tried putting the folder that your images are in in the birt/report/images folder? Or changing the default image directory in your web.xml?
locutuz
Hi,
thanks for your reply.
I just found a solution. The problem only occurred in a deployed application when the plugins are in JAR-Files. So I extracted the images (and the report-design) in a fragment, that is unzipped in the deployed application. Now the relative path could be resolved again.
Thanks for your help.
Regards
Sebastian
mwilliams
Glad you got it working. Let us know whenever you have questions!