How to Generate Barcodes in iReports using Java Barcode?
Top
- Create a new report
- Add barcode.jar to report classpath.
Select menu "Tools ", "Options ", then select "classpath" tab. add barcode.jar to the classpath - Drag an image item in Palette to report

- Click "Cancel" button, in "Select an image file" window
- Select the image item, and edit its properties.
Set property "Expression Class" to "net.sf.jasperreports.engine.JRRenderable";
Set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer( com.onbarcode.barcode.jasper.BarcodeGenerator.draw(2, "12345", "", "X=2&Y=60"))";
BarcodeGenerator.draw method accepts 4 parameters:
the first is the barcode type in int,
the second is the barcode data to encode, in String,
the third is the supplement barcode data in String,
the last is the barcode settings String. More details about barcode settings string, please check each barcode type property settings - Now you can preview the Code 39 barcode with encoding data "12345" in your report
How to generate barcodes using data from data source?
Top
- Follow the above steps 1 - 4 to create a new report & add library to classpath
- Define the data field in your iReport
- Drag an image item to report from Palette and click "Cancel" in the pop-up window
- Select the image item, and edit its properties and set property "Expression Class" to "net.sf.jasperreports.engine.JRRenderable"
set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer( com.onbarcode.barcode.jasper.BarcodeGenerator.draw(2, $F{data field} + "", "", "X=2&Y=60"))";
iReport Barcode Generator Supporting Barcode Properties
Top
Barcode for iReport - Bar Code Types Generation
- 1D / Linear Barcodes:
- 2D / Matrix Barcodes: Data Matrix, PDF 417, QR Code
