Java Reference
In-Depth Information
After compiling the above JRXML template and filling the resultant binary Jasper
template, we should see a report like the following:
As we can see from the example, we can create a circle by using the same values
for the
width
and
height
attributes of the
<reportElement>
element inside the
<ellipse>
element.
Adding Images to a Report
Images can be added to a report by using the JRXML
<image>
element. Report
images can be loaded from memory, from disk, or from a URL. The location from
where to obtain the image is determined by the
<imageExpression>
sub-element of
the
<image>
element.
The following example illustrates how to add an image to a report:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "-//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="ImageDemoReport">
<background>
<band height="391">
<image>
<reportElement x="65" y="0" width="391" height="391"/>
<imageExpression class="java.lang.String">
<![CDATA["reports/company_logo.gif"]]>
</imageExpression>
</image>
</band>
</background>
</jasperReport>