How to generate GS1-128 barcodes in JasperReport?
Here are simple steps to create a GS1-128 (EAN-128) barcode in iReport. View details: How to generate and print barcodes in iReport reprts.
One more guide for you to stream GS1-128 barcodes in iReport using Java Barcode Generator buildin Servlet web application.
One more guide for you to stream GS1-128 barcodes in iReport using Java Barcode Generator buildin Servlet web application.
- Create a new report, and add barcode.jar to report classpath from the downloaded evaluation package
- Drag an image item in Palette to report
- Click "Cancel" button, in "Select an image file" window
- Right click on the image and edit its "Properties", and set property "Expression Class" to "net.sf.jasperreports.engine.JRRenderable";
- To input GS1-128 barcode data manually, set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(
com.onbarcode.barcode.jasper.BarcodeGenerator.draw(13, "(12)12345", "", "X=2&Y=60"))" - To print GS1-128 with data from database, please set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(
com.onbarcode.barcode.jasper.BarcodeGenerator.draw(13, $F{data field} + "", "", "X=2&Y=60"))";
BarcodeGenerator.draw method accepts 4 parameters:
the second is the barcode data to encode, in String,
the last is the barcode settings String. More details about barcode settings string, please check the GS1-128 property table below
GS1-128 Barcode Basic Characteristics in JasperReport Reports
GS1-128 (EAN-128) has specific characteristics that define its encodable data and structure. These characteristics are automatically handled by the JasperReport Barcode Generator Library, but understanding them helps in configuring and troubleshooting your JasperReport GS1-128 barcodes.
Encodable Character Set
GS1-128 supports a specific set of characters, aligned with GS1 General Specifications. The JasperReport Barcode Library automatically handles character encoding, so you only need to ensure your data is correctly formatted. The encodable character set includes:
Note: Do not manually add function characters, code set selection characters, start characters, or stop characters to the "Data" field in the Report Item Property panel. The JasperReport Library will insert these characters automatically to ensure GS1-128 compliance. Manual insertion will cause encoding errors and invalid barcodes.
- The subset of ISO/IEC 646 International Reference Version defined in the GS1 General Specifications. This is the primary character set for AI element strings.
- Characters with ASCII values 128 to 255 (extended ASCII), which can be encoded in GS1-128 symbols (via the Code 128 symbology foundation).
- Four non-data function characters:
- FNC1: Used to indicate the start of a GS1 data string (automatically inserted by the JasperReport Barcode Library).
- FNC2: Not used in GS1-128 barcodes. No need to configure this in the Report Item Property panel.
- FNC3: Not used in GS1-128 barcodes. No configuration required.
- FNC4: Not used in GS1-128 barcodes. No configuration required.
- Four code set selection characters (including single character code set shift). Automatically inserted by the JasperReport Library based on the data being encoded.
- Three start characters and one stop character. Also automatically inserted by the JasperReport Barcode Library.
Note: Do not manually add function characters, code set selection characters, start characters, or stop characters to the "Data" field in the Report Item Property panel. The JasperReport Library will insert these characters automatically to ensure GS1-128 compliance. Manual insertion will cause encoding errors and invalid barcodes.
GS1-128 Check Digit Character
Like Code 128 (its foundation), GS1-128 includes one mandatory symbol check character. This check digit ensures data integrity and is critical for reliable scanning.
- The check digit is automatically calculated and added by the JasperReport Barcode Library. You do not need to manually compute or add it.
- The check digit is not displayed in the Human Readable Interpretation (HRI). The text shown below the barcode.
GS1-128 (EAN-128) Barcode Dimension Size in JasperReport Reports
You can fully customize the dimension size of GS1-128 barcodes in JasperReport reports to meet your report design and scanning requirements. All dimension settings are configured in the Report Item Property panel.
The following dimension properties are available in the Report Item Property panel for GS1-128 barcodes.
The following dimension properties are available in the Report Item Property panel for GS1-128 barcodes.
- UOM (Unit of Measure): The unit used for all dimension settings. Three options are available: PIXEL, CM, or INCH. Select the unit that aligns with your report's Page Format (Paper size, e.g., A4, Letter).
- X: The width of the narrow bar module (the smallest unit of the barcode). The minimum width is defined by your application's specifications. Ensure it is sufficient for scanning (typically 1-3 pixels for digital reports, 0.1-0.3 mm for printed reports).
- Y: The height of the barcode module (the vertical length of the bars). A sufficient height (e.g., 60-120 pixels) ensures readability.
- LeftMargin, RightMargin: The Margin (External spacing around an element) or quiet zone around the GS1-128 barcode. The minimum width of each margin is 10X (10 times the narrow bar width X). This is a GS1 requirement for reliable scanning.
- TopMargin, BottomMargin: Vertical spacing around the barcode (optional but recommended) to avoid overlapping with other report elements, such as Static Text (Fixed label text) or Text Field (Dynamic field displaying data/variables).
JasperReport Barcode GS1-128 Generator - Property Settings
| Category | Properties | Value | Comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Basic | Property: Data | Type: expression
Default: ""
|
Barcode value to encode.
GS1 128 / EAN 128 Valid Data Char Set:
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Add CheckSum Char |
Type: boolean
Default: false |
Add CheckSum Char property is not applied here. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| GS1 128 EAN 128 Special |
Property: Process Tilde |
Type: boolean
Default: false |
Set the Process Tilde property to true, if you want use the tilde character "~"
to specify special characters in the input data.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Barcode Size Related |
Property: Unit of Measure |
Type: int
Default: 0 (pixel) |
Unit of meature for all size related settings in the library.
Valid values: 0: pixel; 1: inch; 2: cm. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: X |
Type: float
Default: 1 |
Width of barcode bar module (narrow bar), default is 1 pixel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Y | Type: float
Default: 30 |
Height of barcode bar module, default is 30 pixel | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Left Margin | Type: float
Default: 0 |
Barcode image left margin size. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Right Margin | Type: float
Default: 0 |
Barcode image right margin size. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Top Margin | Type: float
Default: 0 |
Barcode image top margin size. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Bottom | Type: float
Default: 0 |
Barcode image bottom margin size. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Resolution (in dpi) | Type: int
Default: 72 |
Barcode image resolution in DPI (Dots per inch). | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Rotate |
Type: int
Default: 0 (rotate angle in 0 degree) |
Valid values:
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Font Style |
Property: Show Text |
Type: boolean
Default: true |
If true, display barcode data text under the barcode, otherwise do not display. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Text Font Size |
Type: int
Default: 11 |
Barcode text font size. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Property: Text Margin |
Type: float
Default: 6 |
Space between barcode and barcode data text, default is 6 pixels | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Summary
This guide has covered how to create and customize GS1-128 (EAN-128) barcodes in JasperReport reports using Jaspersoft Studio or iReport Designer. We covered all key aspects, including basic GS1-128 generation, data formatting, encodable character sets, check digit handling, and dimension customization.
