Hi All,
Please guide me how to embed an image into my jasperreport jasper file. I have this directory structure.
Tomcat Root
webapps
reports
-->images
--> company_logo.jpg
-->reports
-->sample.jasper
-->WEB-INF
-->classes
..and I tried doing this thinking that this is relative to my reports context root
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["images/company_logo.jpg"]]>
</imageExpression>
</image>
..and this also
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["/images/company_logo.jpg"]]>
</imageExpression>
</image>
but it always says there was an error loading bytes from location JRLoader.
I tried doing this and it works, but I am a bit confused why my first two attempt doesnt. Is this really how you embed images in jasperreports? I mean you need to supply the whole path? I am thinking that there should be a page relative something.
<image>
<reportElement x="0" y="0" width="104" height="40"/>
<imageExpression class="java.lang.String">
<![CDATA["http://localhost:8080/reports/images/company_logo.jpg"]]>
</imageExpression>
</image>
I am a bit puzzled whats the correct way. Can somebody help me please? Thanks.