|
Home > Java Barcode Generator
> Java Barcode Generation Guide
> Java Data Matrix Barcodes Generator
Java Data Matrix Barcode Generator
Generating Barcode Data Matrix in Java, Jasper, BIRT projects
- Easily generate Data Matrix barcodes in Java applications
- Compatible with the latest Data Matrix ISO specification [ISO/IEC 16022 (Second edition 2006-09-15)]
- Generate high quality Data Matrix images in JPEG, GIF & PNG formats
- 100% build in Java, compatible with JDK 1.4 and later version
- Generate Data Matrix barcodes on any platforms with a Java virtual machine
- Generate Data Matrix in Jasper Reports & iReport
- Generate Data Matrix in Eclipse BIRT
- Mature Java Barcode Generator library since 2003
- Royalty-free and perpetual developer license
Quick Navigate
1. Java Data Matrix Introduction
Data Matrix is also known as Data Matrix, ECC200.
Compatibility: Barcode for Java library is compatible with the latest Data Matrix ISO specification [ISO/IEC 16022 (Second edition 2006-09-15)]
DataMatrix is a two-dimensional
(2D) barcode symbology which can store from 1 to about 2,000 characters.
DataMatrix ECC200 version supports advanced encoding error checking and
correction algorithms (reed-solomon). Those algorithms allow the recognition of
barcodes that are up to 60% damaged.
DataMatrix is being used to encode product and serial number
information on electrical rating plates; to mark of surgical instruments in
Japan; to identify lenses, circuit boards, and other items during
manufacturing.
Barcode Library supports all DataMatrix Formats and the
data represented in the symbol can be compressed using one of following
algorithms.
-
Auto (0): Barcode library will decide the best data mode for you.
-
ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127). This is the default encoding format by Barcode Library.
-
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.

Sample of a DataMatrix Barcode
2. Java Data Matrix Encoding Data Scope
Data Matrix Barcode for Java supports:
- all 128 characters of ASCII
- values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.
3. How to Generate Data Matrix Barcode in Java Class?
The following Java code illustrates how to create a Data Matrix barcode, and output to various formats
1 DataMatrix barcode = new DataMatrix();
2 barcode.setData("DATA MATRIX");
// add more Data Matrix property settings here
3 barcode.renderBarcode("c:/barcode.gif");
4 BufferedImage bufferedImage = barcode.renderBarcode();
5 byte[] barcodeBytes = barcode.renderBarcodeToBytes();
6 Graphics2D g = ...
7 Rectangle2D rectangle = ...
8 barcode.renderBarcode(g, rectangle);
9 OutputStream outputStream = ...
10 barcode.renderBarcode(outputStream);
- Create a DataMatrix barcode object (line 1)
- set DataMatrix object barcode properties (line 2)
- Generate data matrix barcode and encode into gif image format (line 3)
- Generate data matrix and output to BufferedImage object (line 4)
- Generate data matrix in bitmap and output to byte[] (line 5)
- Generate data matrix and draw to defined area (Rectangle2D) on Graphics2D (line 6-8)
- Generate data matrix and output to OutputStream (line 9-10)
4. How to Generate Barcode Data Matrix Image in Java Web Applications?
There are two methods to create Data Matrix barcode images in your Java web applications.
-
The simplest way is to stream barcode image using our buildin barcode servlet application.
- Download the Barcode for Java Trial Package, and unzip it.
- Under java_barcode_trial package, copy barcode folder to your java servlet container like tomcat.
- Restart tomcat. Now you have installed successfully.
- To test your installation, open your web browser and navigate to
http://YourDomain:Port/barcode/datamatrix?Data=123456789
- To create barcode image in your JSP or html page, you need pass the url to IMG tag src value.
For example,
<img src="http://YourDomain:Port/barcode/datamatrix?Data=123456789" />
Using this method, it will not generate any barcode images in your server side.
-
The second method is to generate barcode images in your server side
5. How to Generate Barcode Data Matrix Image in Jasper Reports, iReport, Eclipse BIRT?
6. Java Data Matrix Property Settings
-
Set the data property with the value to encode. Type is String.
Servlet URL Parameter: "Data".
-
Set the dataMode property.
Valid value is DataMatrix.MODE_AUTO (default),
DataMatrix.MODE_ASCII, DataMatrix.MODE_C40,
DataMatrix.MODE_TEXT,
DataMatrix.MODE_X12, DataMatrix.MODE_EDIFACT, DataMatrix.MODE_BASE256.
-
Auto (0): Barcode library will decide the best data mode for you.
-
ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127). This is the default encoding format by Barcode Library.
-
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.
Servlet URL Parameter: "DataMode". Sample: &DataMode=1
-
Set the format property. Type is int. Default is DataMatrix.FORMAT_10X10.
Specifies the Data Matrix Format to use on that symbology.
Valid values see class DataMatrix.FORMAT_*x*;
Servlet URL Parameter: "Format". Sample: &Format=0
-
Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the encoding data. Default is false.
Format of the tilde:
- ~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 - 255.
- ~6NNNNN: is used to represent the Unicode. NNNNN is from 00000 - 65535.
-
~rp: is used only at the very beginning of the symbol for the reader programming
purpose.
-
~m5: is used only at the very beginning of the symbol, the header [)> + ASCII 30
+ ASCII 05 + ASCII 29 will be transmitted by the barcode reader before the data
in the message and the trailer ASCII 30 + ASCII 4 will be transmitted
afterwards.
-
~m6: is used only at the very beginning of the symbol, the header [)> + ASCII 30
+ ASCII 06 + ASCII 29 will be transmitted by the barcode reader before the data
in the message and the trailer ASCII 30 + ASCII 4 will be transmitted
afterwards.
-
~7NNNNNN: is used to specify the Extended Channel Interpretations and NNNNNN is a value between
000000 and 999999.
Servlet URL Parameter: "ProcessTilde". Value: "t" (true), "f" (false). Sample: &ProcessTilde=t
-
Data Matrix can be divided into multiple data areas. Conversely, information stored in multiple Data Matrix symbols can be reconstructed as single data symbols.
One data symbol can be divided into up to 16 symbols.
- Set
isStructuredAppend property to true, then Structured Append is enabled.
Servlet Parameter: "IsStructuredAppend".
- Set
symbolCount property to the number of total symbols which make the sequence.
Servlet Parameter: "SymbolCount".
- Set
symbolIndex property to the position of current symbol in the secuence (Start with 0).
Servlet Parameter: "SymbolIndex".
- Set
fileID property to be identified to the same file.
Servlet Parameter: "FileID".
-
Set the fnc1Mode property.
Servlet URL Parameter: "FNC1Mode". Sample: &FNC1Mode=0
-
Setting up barcode image size:
-
Set property uom (Unit of Measure) for properties X, Y, leftMargin, rightMargin, topMargin and bottomMargin.
Default is Linear.UOM_PIXEL (0). Valid values are Linear.UOM_PIXEL (0), Linear.UOM_CM (1), Linear.UOM_Inch (2).
Servlet URL Parameter: "UOM". Value: 0 (pixel), 1 (cm), 2 (inch). Sample: &UOM=0
-
Set the moduleSize (for barcode module width & height) property.
Type is float. Default is 5.
Servlet URL Parameter: "ModuleSize". Sample: &ModuleSize=5
-
Set the leftMargin, rightMargin, topMargin and bottomMargin properties, and types are all float.
Default values are 0 for all 4 margin settings.
Servlet URL Parameter: "LeftMargin", "RightMargin", "TopMargin", "BottomMargin". Sample: &LeftMargin=0
-
Set the resolution property (Value is expressed in DPI - Dots per inch).
Default is 72 dpi.
Servlet URL Parameter: "Resolution". Sample: &Resolution=72
-
With rotate property, you can display barcode horizontally or vertically.
Value can be
- 0 (Linear.ANGLE_0),
- 1 (Linear.ANGLE_90),
- 2 (Linear.ANGLE_180),
- 3 (Linear.ANGLE_270)
Default value is 0.
Servlet URL Parameter: "Rotate". Sample: &Rotate=0
7. How to Set Generated Barcode Data Matrix Image Size?
All Java Barcode Types/Symbologies
|