Java Data Matrix Generator generate, create 2d barcode Data Matrix images in Java application

Generate, Create, Print, Draw Data Matrix barcode in Java projects


  • Easy to Generate Data Matrix in Java class, Java Bean, Applet, Swing applications
  • Create Data Matrix in Java Servlet, JSP, EJB, Tomcat, JBoss server side projects
  • Print, draw Data Matrix barcode images in Jasper Reports, iReport & Eclipse BIRT Java reporting software
  • Encoding, generating high quality Data Matrix BarCode images in GIF, JPEG, PNG, & EPS formats
  • Compatible with ISO / IEC 16022 (2nd edition 2006-09-15)
  • 100% written in Java for JDK 1.4.2 and later versions
  • Simple to redistribute Java Data Matrix barcode library. No registration key. No activation code
  • Mature Data Matrix barcode generation Java library


Index
 

Java Data Matrix Generator Introduction

Java Barcode Generator library includes a set of Java API which supports generating Data Matrix, and other 20+ linear, 2d barcode symoboglies in your Java applications.

You can download the trial package of Java Barcode library to generate Data Matrix in your Java projects. The download the package includes compiled Java barcode generate SDK (a single Jar file), detailed tutorial for creating barcodes in Java, and complete sample Java source code to generate Data Matrix in Java class. Using downloaded Java barcode generation SDK, you can also easily create and print QR Code, PDF417, Code 39, Code 128, UPC, ITF14, and other 1d and 2d barcodes.

 

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.

 

Java Data Matrix Generator - Valid Data Scope

Java Data Matrix Generator encodes:

  • all 128 characters of ASCII

  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.



 

Java Barcode Data Matrix Generation FAQ?

  1. How to generate 2d barcode Data Matrix in Java class? (Complete Java Data Matrix Generator Demo Source Code)

    // 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. How to generate & encode Data Matrix barcodes to EPS?

    // 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. How to create & encode Data Matrix image 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. How to create & print barcode Data Matrix image in Java Servlet class?

    import com.onbarcode.barcode.AbstractBarcode; 
    import com.onbarcode.barcode.DataMatrix; 
    import javax.servlet.http.HttpServlet; 
    import javax.servlet.http.HttpServletRequest; 
    import javax.servlet.http.HttpServletResponse; 
    import javax.servlet.ServletException; 
    import javax.servlet.ServletOutputStream; 
       
    public class BarcodeServlet extends HttpServlet 
    { 
        public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException 
        { 
            try { 
                DataMatrix barcode = new DataMatrix(); 
                barcode.setData("Data Matrix"); 
                     
                ServletOutputStream servletoutputstream = response.getOutputStream(); 
                  
                response.setContentType("image/jpeg"); 
                response.setHeader("Pragma", "no-cache"); 
                response.setHeader("Cache-Control", "no-cache"); 
                response.setDateHeader("Expires", 0); 
               
                // Generate DataMatrix barcode & output to ServletOutputStream
                barcode.drawBarcode(servletoutputstream); 
          
            } catch (Exception e) { 
                throw new ServletException(e); 
            } 
        } 
    } 


  5. How to generate GS1 compatible Data Matrix?



    1. You need set property fnc1Mode value to IBarcode.FNC1_ENABLE (1), to indicate that the generated data matrix is GS1 compatible.


    2. You can use 2 methods to input GS1 AI elements

      1. Parenthesis: to use parenthesis to indicate an AI code. Eg. (01)12345


      2. Escape Tilde: to use ~ai* to indicate an AI while * is digit number of the AI (from 2 ~ 7). Eg. ~ai20112345 same as (01)12345

        Note:

        1. To use escape tilde, you need set processTilde property to true.

        2. You can not use parenthesis character in the data message, except, user enables ProcessTilde flag and use ~040 and ~041 to replace '(' and ')' Parenthesis must in pair, otherwise, the output would be incorrect.


  6. Data Matrix Reader Programming and Macro 05, Macro 06


    To encode Data Matrix reader programming, macro 05 and macro 06, you need set procesTilde property to true, and add one of the following message to the beginning of the encoding Data Matrix data

    1. ~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".

    2. ~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".

    3. ~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".


  7. How to generate & print barcode Data Matrix image in Jasper Reports?



    Complete Guide for Barcode Generation in Jasper Reports

  8. How to generate & print barcode Data Matrix image in iReport?



    Complete Guide for Barcode Generation in iReport

  9. How to generate & print barcode Data Matrix image in Eclipse BIRT?



    You can stream barcodes into your BIRT reports using Java Barcode Generator.

    However we recommend you use our BIRT Barcode Generator Plugin to generate and print Data Matrix 2D barcodes in your BIRT reports.

  10. How to set generated barcode Data Matrix image width and height?

    1) You can set barcode image width and height through properties barcodeWidth and barcodeHeight values.

    or

    2) You can set X (bar module width) and Y (bar module height) values

 

Java Data Matrix Generator - Property Settings


Java Data Matrix Generator in Java Class: com.onbarcode.barcode.DataMatrix

Category Properties Value Comments
Basic Property: data
URL: DATA
Type: String
Default: ""
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
iReport & 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: dataMode
iReport & URL: DATA-MODE
Type: int

Default: 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.
Property: formatMode
iReport & URL: FORMAT-MODE
Type: int

Default: 0 (DataMatrix.F_10X10)
Specifies the Data Matrix Format to use on that symbology. Valid values see class DataMatrix;
Property: fnc1Mode
iReport & URL: FNC1MODE
Type: int

Default: IBarcode.
FNC1_NONE (0)
To encode GS1 compatible Data Matrix barcode, you need set fnc1Mode value to IBarcode.FNC1_ENABLE (1).
Property: structuredAppend
iReport & URL: STRUCTURED-APPEND
Type: boolean
Default: false
Set StructuredAppend property to true, then Structured Append is enabled.
Property: symbolCount
iReport & URL: SYMBOL-COUNT
Type: int
Default: 0
Set SymbolCount property to the number of total symbols which make the sequence.
Property: symbolIndex
iReport & URL: SYMBOL-INDEX
Type: int
Default: 0
Set SymbolIndex property to the position of current symbol in the secuence (Start with 0).
Property: fileId
iReport & URL: FILE-ID
Type: int
Default: 0
Set FileId property to be identified to the same file.
 
Barcode
Size
Related
Property: autoResize
iReport & URL: AUTO-RESIZE
Type: boolean
Default: false
Auto resize the generated barcode image
Property: barAlignment
iReport & URL: BAR-ALIGNMENT
Type: int
Default: 1 (center)
Barcode horizontal alignment inside the image. 0: left, 1: center, 2: right.
Property: uom
iReport & URL: UOM
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
iReport & URL: X
Type: float
Default: 3
Barcode bar module width and height, default is 3 pixel
Property: barcodeWidth
iReport & URL: BARCODE-WIDTH
Type: float
Default: 0
Barcode image width.

If barcodeWidth setting is smaller than the barcode required minimum width, the library will automatically reset to barcode minimum width.
Property: barcodeHeight
iReport & URL: BARCODE-HEIGHT
Type: float
Default: 0
Barcode image height.

If barcodeHeight setting is smaller than the barcode required minimum height, the library will automatically reset to barcode minimum height.
Property: leftMargin
iReport & URL: LEFT-MARGIN
Type: float
Default: 0
Barcode image left margin size.
Property: rightMargin
iReport & URL: RIGHT-MARGIN
Type: float
Default: 0
Barcode image right margin size.
Property: topMargin
iReport & URL: TOP-MARGIN
Type: float
Default: 0
Barcode image top margin size.
Property: bottomMargin
iReport & URL: BOTTOM-MARGIN
Type: float
Default: 0
Barcode image bottom margin size.
Property: resolution
iReport & URL: RESOLUTION
Type: int
Default: 72
Barcode image resolution in DPI (Dots per inch).
Property: rotate
iReport & URL: ROTATE
Type: int
Default: 0 (IBarcode.ROTATE_0)
Valid values:

  • 0 (IBarcode.ROTATE_0)
  • 1 (IBarcode.ROTATE_90)
  • 2 (IBarcode.ROTATE_180)
  • 3 (IBarcode.ROTATE_270)
 
Barcode
Colors
Property: backColor
iReport & URL: BACK-COLOR
Type: Color
Default: white
Barcode image background color
Property: foreColor
iReport & URL: FORE-COLOR
Type: Color
Default: black
Barcode image foreground color
 
In WebStream query string, please use int value for Enums, "true" and "false" for bool.









OnBarcode is a market-leading provider of barcode generator, reader controls and components for ASP.NET, Windows Forms, WPF, as well Java, Android, iOS (iPhone, iPad) across all major enterprise development platforms. We provides high quality tutorials and guides for various linear, 2d barcode information, such as C# Barcode, QR Code C#, QR Code VB.NET, QR Code ASP.NET, QR Code .NET, ASP.NET Barcode. OnBarcode products support most common barcode symbologies including QRCode C# SDK, Data Matrix in C#.net Control, PDF-417 Componennt in C# .NET, Code 128 VS .net sdk, Code 39 C# library.
Terms of Use | Privacy Policy
Copyright © OnBarcode.com . All rights reserved.