.NET Barcode for WinForms          ASP.NET Barcode          .NET Barcode Reader          Java Barcode          Java Barcode Reader
Home > Java Barcode > Java Data Martrix Generator

Java Data Martrix Generator

Java Data Martrix Generation package to generate Data Martrix barcode in Java applications.

  • Mature Java Data Martrix package consists of class library contains all necessary class files for java Data Martrix barcode generation.

  • Easy integration into your Java IDEs.

  • Generate, create Data Martrix in Java class, Java bean, Servlet, EJB.

  • Servlets, Applets, JavaBean and class library are provided in each Java Data Martrix generation package.

  • Generate Data Martrix barcodes in Jasper Reports, iReport & Eclipse BIRT

  • Java Data Martrix generator is compatible with JDK 1.4.0 or greater.


Java Data Martrix Generator - Overview

Java Data Martrix generator is a mature and reliable Java barcode generation component for creating Data Martrix barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects. High-quality Data Martrix barcode images can be drawn and printed into GIF, BMP, PNG, JPEG/JPG & TIFF formats with Java Data Martrix barcode generator. Rich barcode options are provided to customize Data Martrix barcode properties in accordance with your needs.


Data Martrix information:

Data Martrix:one of 2D barcode symbologies, was designed by Siemens to encode a great number of information within a small space. It is made up of data regions with black and white modules and “cells” in a square or rectangular pattern and is widely used in the marking of small items such as integrated circuits and printed circuit boards.

Available encoding data:

ASCII 1-255

Variable data length

The structure of an Data Martrix:

1. Data area: contains the data in compiled form.
2. Closed limitation line: is the corner represented in normal alignment to the left and with an uninterrupted line under the data area.
3. Open borderline: located in the opposite corner of the "closed limitation line"(above and to the right), contain alternating black and white dots.
4. Quiet zone: The code is surrounded by it. It must be at least as wide as one dot of the code.


Java Data Martrix Generator Implementation to Generate Data Martrix

1. Generate Data Martrix in Java class with the changing of barcode properties.

// Create Java Data Matrix object
DataMatrix barcode = new DataMatrix();

// Set Data Matrix data text to encode
barcode.setData("DataMatrix-IN-JAVA");

// Generate Data Matrix barcode & print into Graphics2D object
barcode.drawBarcode("Java Graphics2D object");

// Generate Data Matrix barcode & encode into GIF format
barcode.drawBarcode("C://barcode-datamatrix.gif");

// Generate Data Matrix barcode & encode into JPEG format
barcode.drawBarcode("C://barcode-datamatrix.jpg");


2. Generate & encode ISBN to EPS with changing the values concerned.

// Create Java Data Matrix object
DataMatrix barcode = new DataMatrix();

// Set Data Matrix data text to encode
barcode.setData("Create Data Matrix in EPS");

// Generate Data Matrix barcode & encode into EPS
barcode.drawBarcode2EPS("C://barcode-datamatrix.eps");


3. Generate & encode ISBN in html or jsp pages.

Under demo package, copy barcode folder and its contents to your tomcat.

Start tomcat, navigate to http://YourDomain:Port/barcode/barcode?DATA=DataMatrixEncodingData&TYPE=datamatrix

To create bar code images in html or jsp pages, you can insert a image tag (img) into your page.

For example, <img src="http://YourDomain:Port/barcode/barcode?DATA=DataMatrixEncodingData&TYPE=datamatrix" />


4. Two ways to set the width and height of generated barcode Data Martrix image.

1. Set the values of the barcodeWidth and barcodeHeight properties.
or
2. Set X (bar module width) and Y (bar module height) values

Data Martrix Property Settings in Java Barcode Generator

Data Martrix Basic Settings

Properties Value
Comments
Property URL Options Default
data DATA (Data to encode in the Data Martrix) ""

Data Martrix value to encode

Data Martrix Character 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 Martrix Special Settings

Properties Value
Comments
Property URL Options Default
topTextFont
TOP-TEXT-FONT
Font
new Font("Arial", Font.PLAIN, 11) Text above barcode font style.

In Java Servlet web streaming, using the url paramter in the following format:
&TEXT-FONT=Arial|plain|11
topTextColor
TOP-TEXT-COLOR
Font
black Text above barcode color
supData
SUP-DATA
String
"" Set the supplement data to encode. Valid values are 2 or 5 digits
supHeight
SUP-HEIGHT
float
0.8of A multiplicator of the height of the bar module; The default is 0.8 (80% of Y - bar module height).
supSpace
SUP-SPACE
float
15 The separation between the barcode and the supplement. Default is 15 pixel.

Data Martrix Text Settings

Properties Value
Comments
Property URL Options Default
processTilde

PROCESS-TILDE
true or false
true

Default value true is for using the tilde character "~" to specify special characters in the input data.

  • 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".


dataMode

DATA-MODE
int

0

(DataMatrix.M_AUTO)


Data Matrix data encoding mode.

Valid values are:

DataMatrix.M_AUTO (0): Barcode library will decide the best data mode for you. This is the default encoding format by Barcode Library.
DataMatrix.M_ASCII (1): it is used to encode data that mainly contains ASCII characters (0-127).
DataMatrix.M_C40 (2): it is used to encode data that mainly contains numeric and upper case characters.
DataMatrix.M_TEXT (3): it is used to encode data that mainly contains numeric and lower case characters.
DataMatrix.M_X12 (4):it is used to encode the standard ANSI X12 electronic data interchange characters.
DataMatrix.M_EDIFACT (5): it is used to encode 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111).
DataMatrix.M_BASE256 (6): it is used to encode 8 bit values.



formatMode
FORMAT-MODE
int
0(DataMatrix.F-10X10)

Specifies the Data Matrix Format to use on that symbology. Valid values see class DataMatrix;

fnc1Mode
FNC1-MODE
int
IBarcode.
FNC1_NONE (0)

IBarcode. FNC1_ENABLE (1) value is to encode GS1 compatible Data Matrix barcode.

symbolCount
SYMBOL-COUNT
int
0

The symoblolCount property is for the sequence.

symbolIndex
SYMBOL-INDEX
int
0
The symbolIndex property is for the postion of current symbol in the secuence(start with 0)

field
FILE-ID
int
0

The field property is to be identified to the same file.

Data Martrix Size Settings

Properties Value
Comments
Property URL Options Default
rotate

Rotate
Degree0, 90, 180, 270
0(IBarcode.ROTATE_0)

Rotate the Angle of the Data Martrix images

autoResize

AUTO-RESIZE
true or false
false

Auto resize the generated barcode image

barcodeHeight
BARCODE-HEIGHT
float
0

Barcode image Height

barcodeWidth
BARCODE-WIDTH
float
0

Barcode image Width

bottomMargin
BOTTOM-MARGIN
float
0

Barcode image bottom margin size
leftMargin LEFT-MARGINE float 0


Barcode image left margin size

rightMargin RIGHT-MARGIN float 0

Barcode image right margin size.

topMargin TOP-MARGIN float 0


Barcode image Top margin size
barAlignment BARALIGMENT int 1(center)


Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
uom
UOM
Pixel, Cm, or Inch
0(Pixel)

Unit of Measure for all numeric properties.Valid values: 0: pixel; 1: inch; 2: cm.
X X float 1

Width of barcode bar module (narrow bar), default is 1 pixel

Y Y float 30

Height of barcode bar module, default is 30 pixel

Data Martrix Color Settings

Properties Value
Comments
Property URL Options Default
backColor
BACK
-COLOR
Color
white

Barcode image background color

foreColor
FORE
-COLOR
Color
black
Barcode image foreground color

Data Martrix Image Settings

Properties Value
Comments
Property URL Options Default
resolution
RESOLUTION
int
72

Resolution of Codabar Image, Dots Per Inch

Method

// generate barcode and output to OutputStream object
public boolean drawBarcode(OutputStream outputStream) throws Exception

// generate barcode into a new BufferedImage object
public BufferedImage drawBarcode() throws Exception

/*
Use this method to generate barcode, and save into gif or jpeg files
1. to save into gif file, filename ends with ".gif", like "c:\\barcode.gif"
2. to save into jpeg file, filename ends with ".jpg", like "c:\\barcode.jpg"
*/

public byte[] drawBarcodeToBytes() throws Exception

public boolean drawBarcode(String imageFile) throws Exception

// Generate barcode and save into EPS file, the filename must ends with ".eps"
public void drawBarcode2EPS(String filename) throws Exception

// Generate barcode on Graphics2D object within certain area
public void drawBarcode(Graphics2D g, Rectangle2D rectangle) throws Exception