JasperReports Data Matrix Generator Library

Java Barcode Generator Library to create, print Data Matrix images in JasperReports, iReport reports

Data Matrix for iReport plugin generate, create Data Matrix barcode in iReport Jasper Reports

  • Easy to generate Data Matrix barcodes in iReport reports
  • Create a single Data Matrix barcode or bulk bacodes in iReport with data from database
  • Easy to install with no registration key or action code required
  • Print, create high-quality Data Matrix barcodes in Png, Gif, Jpeg image formats
  • Completely developed in NETBeans iReport Custom Extended Report Item framework
  • Flexible settings to adjust Data Matrix barcode parameters
  • Professional iReport Data Matrix barcode generation plugin using Java Barcode Generator library
Here we will learn how to create, print Data Matrix (2D Barcode) in JasperReport reports using Jaspersoft Studio (official Eclipse-based report designer) or iReport Designer (legacy Swing-based report designer).

Here's a concise overview of the full content:
  • Basic steps to quickly generate Data Matrix (Barcode Component) in a JRXML (XML source template file) using Jaspersoft Studio or iReport Designer, including saving, exporting the Data Matrix image to different output formats.
  • Detailed explanations of Data Matrix's valid encoding character sets, maximum data length, and encoding Data Modes, integrated with JasperReport's DataSource (data provider for the report) and Expression (dynamic value using Java/Groovy syntax) features.
  • Step-by-step Java demo codes for advanced data encoding in Data Matrix, including non-printable characters, Unicode text, binary data, and GS1 data elements, with clear property settings in the Report Item Property panel.
  • Customization of Data Matrix dimension sizes (square and rectangular), including advanced settings for modules, units of measure, and Quiet Zones (margin settings), combined with JasperReport's Formatting & Style terms.
  • Configuration of Data Matrix color and image options (raster and vector formats) in JasperReport reports, ensuring alignment with report design requirements.
  • Advanced Data Matrix settings, such as Format Mode, Structured Append mode, and FNC1 mode, with practical operation steps and JasperReport term integration.

iReport Barcode Data Matrix Generator Introduction

Top
iReport Barcode is a NETBeans iReport Custom Extended Report Item which helps you easily generate and print high quality 1D (linear) and 2D (matrix) barcodes in your iReport reports.

Barcode Data Matrix Introduction

Data Matrix code is a two-dimensional matrix barcode consisting of black and white "cells" or modules arranged in either a square or rectangular pattern. The information to be encoded can be text or raw data. Usual data size is from a few bytes up to 2 kilobytes. The length of the encoded data depends on the symbol dimension used. Error correction codes are added to increase symbol strength: even if they are partially damaged, they can still be read. A Data Matrix symbol can store up to 2,335 alphanumeric characters.

iReport Data Matrix Generator - Valid Data Scope

  • all 128 characters of ASCII, including A-Z, a-z, 0-9, etc
  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.

Data Matrix Generators







How to print Data Matrix barcode in iReport?

Top
Users can follow the guide to print Data Matrix barcodes in iReport. More details view here: how to generate and print barcodes in iReport reprts.

Another method to stream Data Matrix barcodes in iReport using Java Barcode Generator buildin Servlet web application.
  1. Download the evaluation package and unzip
  2. Create a new report in iReport, and add barcode.jar to report classpath from the downloaded trial package
  3. Drag an image item in Palette to report
  4. Click "Cancel" button, in "Select an image file" window
  5. Right click on the image and edit its "Properties", and set property "Expression Class" to "net.sf.jasperreports.engine.JRRenderable";
  6. To input Data Matrix barcode data manually, set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(
    com.onbarcode.barcode.jasper.BarcodeGenerator.draw(100, "12345", "", "X=2&Y=2"))
    "
  7. To print Data Matrix with data from database, please set property "Image Expression" to "new com.onbarcode.barcode.jasper.JasperRenderer(com.onbarcode.barcode.jasper.BarcodeGenerator.draw(100, $F{data field} + "", "", "X=2&Y=2"))";

    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 Data Matrix property table below



Data Matrix Barcode Data Characters Encoding in JasperReport Reports

To generate a valid, scannable Data Matrix in JasperReport reports, it's critical to understand its encoding rules, including valid character sets, maximum data length, and Data Modes. All configurations are completed in the Report Item Property panel of Jaspersoft Studio or iReport Designer.


Data Matrix Valid Encoding Character Set

Data Matrix in JasperReport reports supports a range of character sets, which can be flexibly used with JasperReport's DataSource and Field features for dynamic data binding. The supported character sets are:
  • Full ASCII (all 128 characters): This includes standard letters, numbers, symbols, and control characters, making it suitable for most basic encoding needs.
  • Extended ASCII (ISO 8859-1 values 128-255): Supports additional characters such as accented letters, which are common in non-English languages.
  • Other character sets (e.g., Arabic, Cyrillic, Greek, Hebrew): These can be supported by enabling the Extended Channel Interpretation (ECI) protocol in the Report Item Property panel. This is useful for international reports that require non-ASCII character encoding.
Note: When encoding non-ASCII character sets, ensure the DataMode is set correctly and the ECI protocol is enabled if necessary.


Data Matrix Maximum Data Length Size

The maximum data length a Data Matrix can encode depends on its encoding Data Mode. The JasperReports Library automatically optimizes data storage based on the selected mode, but understanding the limits helps avoid encoding errors. The maximum lengths for common Data Modes are:
  • Alphanumeric data: Up to 2,335 characters. This mode is efficient for encoding combinations of letters, numbers, and basic symbols (e.g., product codes, URLs).
  • Byte data (8-bit): 1,555 characters. Suitable for encoding Extended ASCII, binary data, or non-ASCII characters (when used with ECI).
  • Numeric data: 3,116 digits. This mode has the highest encoding efficiency, making it ideal for large sets of numeric data (e.g., serial numbers, inventory codes).
Note: If your data exceeds the maximum length for a single Data Matrix, use the Structured Append mode to split the data across multiple Data Matrix symbols.


Data Matrix Encoding Data Mode

Data Matrix uses six encoding modes (schemes) to efficiently encode different types of data. The JasperReports Library can automatically select the optimal mode for you, or you can manually set it in the Report Item Property panel. Here's how to configure Data Mode in Jaspersoft Studio or iReport Designer:
  • Select the Data Matrix (Barcode Component) in your JRXML template.
  • Open the Report Item Property panel and locate the "DataMode" dropdown.
  • Choose the appropriate mode based on your data type. The available modes (and their use cases) are:
    • DataMatrixDataMode.Auto: The JasperReports Library automatically selects the best mode based on the input data. This is the recommended setting for most use cases, especially when the data type varies.
    • DataMatrixDataMode.ASCII: For encoding double-digit numerics, ASCII values 0-127, and Extended ASCII values 128-255. Use this mode for standard text and basic symbols.
    • DataMatrixDataMode.C40: For upper-case alphanumeric characters, as well as lower-case and special characters. This mode is efficient for mixed-case text.
    • DataMatrixDataMode.Text: For lower-case alphanumeric characters, as well as upper-case and special characters. Similar to C40 but optimized for lower-case text.
    • DataMatrixDataMode.X12: For ANSI X12 EDI (Electronic Data Interchange) datasets. Ideal for supply chain and business-to-business reports.
    • DataMatrixDataMode.Edifact: For ASCII values 32-94, specifically designed for EDIFACT (Electronic Data Interchange for Administration, Commerce, and Transport) data.
    • DataMatrixDataMode.Base256: For all byte values 0-255. Use this mode for binary data, non-printable characters, or custom character sets.
  • Save the JRXML template to apply the DataMode setting.
Example configuration for automatic mode:

In the Report Item Property panel, set "DataMode" to "DataMatrixDataMode.Auto".Enter your data (static or dynamic via Expression) in the "Data" field.The JasperReports Library will analyze the data and select the most efficient encoding mode.

Note: Manually selecting the wrong DataMode can lead to encoding errors or inefficient data storage. Use "Auto" mode if you're unsure of the data type.


Advanced Data Encoding in Data Matrix Using Jaspersoft Studio/iReport

In practical report design, you may need to encode complex data types into Data Matrix, such as non-printable characters, Unicode text, binary data, or GS1 data elements.


Encode Non-Printable Chars in Data Matrix

Some ASCII characters are non-printable (e.g., Carriage Return [CR], Line Feed [LF]) and cannot be directly entered via keyboard. To encode these in Data Matrix, you'll need to use a specific format and configure the appropriate properties in the Report Item Property panel.
  • Select the Data Matrix and open the Report Item Property panel.
  • Set the "ProcessTilde" property to "true". This enables the use of "~" to represent non-printable characters (formatted as "~ddd", where "ddd" is the three-digit ASCII value).
  • Set the "DataMode" property to "DataMatrixDataMode.Base256". This mode supports encoding all byte values, including non-printable characters.
  • In the "Data" field, enter the non-printable character in the format "~ddd". For example, to encode [CR], enter "Data~013Matrix" (inserts [CR] between "Data" and "Matrix").
  • If using dynamic data, use an Expression (e.g., "$F{NonPrintData}") where the Field stores the formatted string (e.g., "Data~013Matrix").
  • Save the JRXML template to apply the settings.




Encode Unicode Text in Data Matrix

You can easily encode Unicode text (e.g., Arabic, Chinese, Cyrillic) into Data Matrix in JasperReport reports using the Report Item Property panel. This is useful for international reports that require non-ASCII text encoding.
  • Select the Data Matrix and open the Report Item Property panel.
  • Locate the "EncodeUnicodeText" property and set it to "true". It enables the JasperReports Library to encode Unicode text from the "Data" field.
  • Enter the Unicode text into the "Data" field. For dynamic data, use an Expression like "$F{UnicodeData}" to reference the Field storing the text.
  • Set the "DataMode" to "DataMatrixDataMode.Auto". The library will automatically select the optimal mode for Unicode encoding.
  • Save the JRXML template to apply the settings.




More Data Formats to Encode in Data Matrix

Data Matrix in JasperReport reports supports additional advanced data formats, which are commonly used in business and industrial scenarios. Below are key formats with brief configuration guidelines (detailed steps can be expanded as needed):
  • Binary data: Encode binary data (e.g., file byte arrays, encrypted data) by setting "DataMode" to "DataMatrixDataMode.Base256" and using the "ProcessTilde" property to format byte values as "~ddd". Bind the binary data to a Field ($F{}) with a BLOB type from a JDBC DataSource.
  • GS1 data elements: Encode GS1 business messages by setting the "FNC1" property to "FNC1.FNC1_1ST_POS" and formatting the data with Application Identifier (AI) codes in parentheses (e.g., "(01)12345678901234").
  • Structured Append mode: Split large data across multiple Data Matrix symbols by enabling the "StructuredAppend" property. This is useful for encoding data that exceeds the maximum length of a single Data Matrix.


Data Matrix Barcode Dimension Size in JasperReport Reports

You can fully customize the dimension size of Data Matrix in JasperReport reports, including square and rectangular formats, module size, and Quiet Zones.


Quick to Create Data Matrix with Specified Width

Data Matrix is typically square, so setting the width will automatically adjust the height to maintain a 1:1 aspect ratio. Follow these steps to set a specific width.
  • Open the Report Item Property panel of the Data Matrix.
  • Locate the "BarcodeWidth" property and enter the desired width (e.g., 900 pixels). The height will automatically match the width to maintain a square shape.
  • Save the JRXML template to apply the setting.




Note: Avoid setting the width too large, as it may overlap with other Report Elements (e.g., Static Text (Fixed label text), Text Field (Dynamic field displaying data/variables)).


Generate Rectangular Data Matrix with Specified Width and Height

Data Matrix (ECC200) supports 6 rectangular symbols with specific row and column configurations. To create a rectangular Data Matrix, you'll need to set the "FormatMode" property and match the width-height ratio to the row-column ratio of the selected format.

List of the size rectangular format:
  • 8 rows x 18 columns
  • 8 rows x 32 columns
  • 12 rows x 26 columns
  • 12 rows x 36 columns
  • 16 rows x 36 columns
  • 16 rows x 48 columns
  • Open the Report Item Property panel.
  • Set the "FormatMode" property to the desired rectangular format (e.g., "DataMatrixFormatMode.Format_16X48" for 16 rows x 48 columns).
  • Set the "BarcodeWidth" and "BarcodeHeight" properties to match the row-column ratio of the selected format. For example, 16 rows x 48 columns has a 1:3 ratio, so set "BarcodeWidth" to 900 and "BarcodeHeight" to 300.
  • Enter the data to encode in the "Data" field (static or dynamic via Expression).
  • Save the JRXML template to apply the settings.




Note: If the data exceeds the maximum capacity of the selected rectangular format, the JasperReports Library will automatically select a larger format to accommodate the data.


Advanced Data Matrix Dimension Settings

You can fine-tune the Data Matrix dimensions using advanced properties in the Report Item Property panel, including module size, unit of measure, and Quiet Zones. The width of a Data Matrix (including Quiet Zones) can be calculated using the formula: W = Row * X + 2Q, where:

W = Barcode widthRow = Modules per row (determined by FormatMode)X = Width of each moduleQ = Width of the Quiet Zone (margin)

Configure the following advanced settings:
  • UOM (Unit of Measure): Select the unit (PIXEL, CM, or INCH) for dimension settings. Default is PIXEL.
  • X: Set the width of each module (minimum width is defined by your application's specifications).
  • FormatMode: Select the Data Matrix symbol size (square or rectangular) as needed.
  • Quiet Zones: Set the LeftMargin, RightMargin, TopMargin, and BottomMargin properties (minimum width is equal to the module width X). These properties control the empty space around the Data Matrix.
  • AutoResize: Set to "false" to manually control dimensions; set to "true" to let the library adjust size based on data.


Data Matrix Color and Image Option Settings in JasperReport Reports

You can customize the colors and image formats of Data Matrix in JasperReport reports to match your report's design. All settings are configured in the Report Item Property panel, and we'll cover both raster and vector image formats.


Colors in Data Matrix

By default, Data Matrix uses a dark (black) foreground (bars) and light (white) background (spaces), but you can customize these colors to align with your report's style. Ensure high contrast between foreground and background to maintain readability.

Configure the color properties:
  • ForeColor: Set the color of the Data Matrix's bars (default: Black). You can select a predefined color or enter a custom RGB value (e.g., #FF0000 for Red).
  • BackColor: Set the color of the Data Matrix's spaces (default: White).
Example configurations:
  • Standard dark-on-light: ForeColor = Black, BackColor = White (default).
  • Light-on-dark: ForeColor = White, BackColor = Black.
  • Custom color: ForeColor = Red, BackColor = White (ensure high contrast).








Image Settings in Data Matrix

Data Matrix in JasperReport reports can be exported as raster images (e.g., PNG, JPEG, BITMAP) or vector images (e.g., SVG, EPS). Vector images are ideal for high-quality printing, while raster images are suitable for digital display.

Configure raster image settings:
  • ImageFormat: Select the desired raster format (e.g., PNG, JPEG) from the dropdown.
  • Resolution: Set the image resolution (e.g., 300 DPI) for high-quality printing.


Create Data Matrix with Advanced Options in JasperReport Reports

JasperReport reports support advanced Data Matrix settings to meet specific business needs, including Format Mode, Structured Append mode, and FNC1 mode.


Data Matrix Format Mode

The Data Matrix ISO standard specifies 24 square symbols and 6 rectangular symbols for ECC 200. Each symbol size has a specific number of rows and columns, which determines its data capacity. You can manually select the Format Mode in the Report Item Property panel to control the Data Matrix size.
  • Select the Data Matrix and open the Report Item Property panel.
  • Locate the "FormatMode" property and select the desired symbol size (e.g., "DataMatrixFormatMode.Format_48X48" for a 48x48 square Data Matrix).
  • Enter the data to encode in the "Data" field.
  • Save the JRXML template to apply the setting.




Note: If the data exceeds the maximum capacity of the selected FormatMode, the JasperReports Library will automatically select a larger format to ensure all data is encoded.


Data Matrix Structured Append Mode

Structured Append mode allows you to split large data into blocks and store it across multiple Data Matrix symbols (up to 16). This is useful for encoding data that exceeds the maximum length of a single Data Matrix.
  • Select the Data Matrix and open the Report Item Property panel.
  • Set the "StructuredAppend" property to "true" to enable the mode.
  • Configure the following properties:
    • SymbolCount: The total number of Data Matrix symbols needed to store the entire data message (e.g., 3 for splitting data into 3 symbols).
    • SymbolIndex: The position of the current Data Matrix in the sequence (starts at 0 for the first symbol).
    • FileId: A unique integer (e.g., 999) that identifies all symbols belonging to the same data message. All symbols must have the same FileId.
  • Enter the portion of the data to encode in the current Data Matrix (e.g., the first 100 characters for SymbolIndex 0).
  • Repeat the process for each symbol (adjust SymbolIndex for each Data Matrix).
  • Save the JRXML template for each symbol (or use a Subreport (Embedded nested report) to generate multiple symbols in a single report).




Data Matrix FNC1 in the First Position

When FNC1 appears in the first position of a Data Matrix, it signals that the encoded data conforms to the GS1 Application Identifier (AI) standard. This is commonly used in supply chain and retail reports to encode product information (e.g., GTIN, batch number).
  • Select the Data Matrix and open the Report Item Property panel.
  • Locate the "FNC1" property and set it to "FNC1.FNC1_1ST_POS".
  • Enter the GS1 data in the "Data" field, with AI codes surrounded by parentheses (e.g., "(01)12345678901234(10)ABC123").
  • Set the "DataMode" to "DataMatrixDataMode.Auto" to ensure correct encoding.
  • Save the JRXML template to apply the setting.




Note: Ensure the AI codes and data lengths comply with the GS1 standard. Incorrect formatting will prevent the scanner from recognizing the GS1 data.

iReport Barcode Data Matrix Generator - Property Settings

Top
Category Properties Value Comments
Basic Property: Data Type: expression
Default: ""
  • If you encode the barcode data text directly, the text string should be around by " " ", such as "12345"

  • If you encode the barcode data from dataset, input the expression, such as row["CUSTOMERNUMBER"]
Barcode value to encode

Data Matrix Valid Data Char Set:

  • ASCII values 0 - 127 in accordance with the US national version of ISO/IEC 646

    NOTE: This version consists of the G0 set of ISO/IEC 646 and the C0 set of ISO/IEC 6429 with values 28 - 31 modified to FS, GS, RS and US respectively.
  • ASCII values 128 - 255 in accordance with ISO 8859-1. These are referred to as extended ASCII.

 
Data Matrix
Special
Property: processTilde
URL: PROCESS-TILDE
Type: bool
Default: true
Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default value is true.

  • 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
    Strings from "~256" to "~299" are unused
  • 2-byte character (Unicode): ~6ddddd (character value from 00000 ~ 65535)
    Strings from "~665536" to "~699999" are unused
  • for GS1 AI Code:
    ~ai2: AI code with 2 digits
    ~ai3: AI code with 3 digits
    ~ai4: AI code with 4 digits
    ~ai5: AI code with 5 digits
    ~ai6: AI code with 6 digits
    ~ai7: AI code with 7 digits
  • ECI: ~7dddddd (valid value of dddddd from 000000 to 999999)
  • ~rp: Reader Programming (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~rpABCD1234".
  • ~m5: 05 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m5ABCD1234".
  • ~m6: 06 Macro (for ASCII mode and Auto mode only)
    This should be located at the beginning of the encoding data, e.g. data = "~m6ABCD1234".
Property: Data Matrix Data Mode Type: int

Default: AUTO
Data Matrix data encoding mode.

Valid values are:
  • AUTO (0): Barcode library will decide the best data mode for you. This is the default encoding format by Barcode Library.
  • ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127).
  • C40 (2): it is used to encode data that mainly contains numeric and upper case characters.
  • TEXT (3): it is used to encode data that mainly contains numeric and lower case characters.
  • X12 (4):it is used to encode the standard ANSI X12 electronic data interchange characters.
  • EDIFACT (5): it is used to encode 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111).
  • BASE256 (6): it is used to encode 8 bit values.
Property: Data Matrix Format Mode Type: int

Default: 10X10
Specifies the Data Matrix Format to use on that symbology. Valid values see options in the list;
Property: Data Matrix FNC1 Mode Type: int

Default: NONE
To encode GS1 compatible Data Matrix barcode, you need set fnc1Mode value to "ENABLE".
Property: 2D Barcode Structured Append Type: boolean
Default: false
Set Structured Append property to true, then Structured Append is enabled.
Property: 2D Barcode Symbol Count Type: int
Default: 0
Set Symbol Count property to the number of total symbols which make the sequence.
Property: 2D Barcode Symbol Index Type: int
Default: 0
Set Symbol Index property to the position of current symbol in the secuence (Start with 0).
Property: 2D Barcode File Id Type: int
Default: 0
Set File Id property to be identified to the same file.
 
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: 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:

  • 0 (rotate angle in 0 degree)
  • 90 (rotate angle in 90 degree)
  • 180 (rotate angle in 180 degree)
  • 270 (rotate angle in 270 degree)


Summary

This guide has provided a comprehensive, step-by-step approach to generating and customizing Data Matrix (a type of 2d Barcode) in JasperReport reports using Jaspersoft Studio or iReport Designer. We covered all key aspects, including basic generation, data encoding (standard and advanced), dimension customization, color and image settings, and advanced modes like Structured Append and FNC1.







































Start with free trial package:








































Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.