Design Reports using iReport and Render Barcode Images

In this article, we show how to use iReport to design reports. iReport is a plug-in for Netbeans which can be used to design reports for JasperReports visually. The JasperReports .jrxml file is generated by the iReport designer.

To download and install iReport, please go to the iReport plug-in site: http://sourceforge.net/projects/ireport/.

Working with iReport

After iReport has been installed as a Netbeans plug-in:

  1. Open Netbeans
  2. Select the Welcome Window in iReport from the menu

iReport QuickStart Window

todo:image_alt_text

  1. Click Step 1 and create an empty datasource connection, if it’s not already there in the list on top.
  2. Click Step-2 to create a new report.
  3. Select Blank A4 from the page layout list.
  4. Click Launch Report Wizard.
  5. Name the report report1.
  6. Select an empty datasource connection in the next step and proceed to complete the wizard. After the report is created in the specified location, it opens in the iReport designer within Netbeans.
  7. Click the Palette window and drag an image from the Palette to the report. We will use this image to render a barcode using Aspose.BarCode for JasperReports.

The Palette window

todo:image_alt_text

  1. Set the image properties as follows:
    • Image expression: new com.aspose.barcode.jr.BarCodeRenderer(com.aspose.barcode.jr.BarCodeAttributesFactory.Create(“test”,“DataMatrix”,java.awt.Color.RED))
    • Expression class: net.sf.jasperreports.engine.JRRenderable
  2. Go to the XML tab in the report. It contains the the following XML for the image tag:

 	<reportElement x="103" y="0" width="201" height="174"/>

	<imageExpression class="net.sf.jasperreports.engine.JRRenderable"><![CDATA[new com.aspose.barcode.jr.BarCodeRenderer(com.aspose.barcode.jr.BarCodeAttributesFactory.Create("test","DataMatrix",java.awt.Color.RED))]]></imageExpression>


Finally, the report is saved as a .jrxml file.

To compile and generate the report, get more information from the Developer Guide.