Reputation: 1422
i want to add several image to my PDF report, here is my views.xml
<bean id="form_b" class="org.springframework.web.servlet.view.jasperreports.JasperReportsPdfView"
p:url="/WEB-INF/jasper/form_b.jasper">
<property name="headers">
<props>
<prop key="Content-Disposition">
attachment; filename=form_b.pdf
</prop>
</props>
</property>
</bean>
i have an image file located here: "WEB-INF/images/logo.jpg" how can i embed it to my jasper pdf report ?
Upvotes: 1
Views: 3276
Reputation: 120811
The only thing you need to do is, is to insert it in you jrxml file:
<image scaleImage="RetainShape" hAlign="Left" vAlign="Bottom">
<reportElement x="0" y="0" width="758" height="60" />
<imageExpression>"reports/test.png"</imageExpression>
</image>
In this case the images are located in WEB-INF/classes/reports.
I would not like to place the images in an other directory then WEB-INF/classes (or a subdirectory of that), because placeing them there (WEB-INF/classes) makes it easy to write unit tests that check if the jasper reports works fine.
Upvotes: 3