You can reference the image directly in the report:
<image>
<reportElement x="0" y="0" width="150" height="60"/>
<imageExpression><![CDATA["static/images/header.png"]]></imageExpression>
</image>
Or pass it into the report by parameter as an Image
instance:
BufferedImage image = ImageIO.read(getClass().getResource("/static/images/header.png"));
parameters.put("header", image);
And use it in the report like this:
<image>
<reportElement x="0" y="0" width="150" height="60"/>
<imageExpression><![CDATA[$P{header}]]></imageExpression>
</image>
Where header
parameter class in report is as Object
.
Or pass it as an URL
instance:
URL headerUrl = getClass().getResource("/static/images/header.png");
parameters.put("header", headerUrl);
Where header
parameter class in report is as URL
.
<parameter name="header" class="java.net.URL" isForPrompting="false">
<defaultValueExpression><![CDATA[]]></defaultValueExpression>
</parameter>
Then the imageExpression
in image
element is the same as in previous example.