Java Barcode Data Matrix Generator

Create, Generate, Draw, Print Data Matrix in Java Application


  • Easy to generate Data Matrix barcodes in Java Class, J2EE applications
  • Simple to redistribute Java Data Matrix barcode library. No registration key. No activation code.
  • Generating high quality Data Matrix Bar Code images in GIF, PNG, JPEG, EPS & BITMAP
  • Generate Data Matrix barcodes in Jasper Reports, iReport & Eclipse BIRT
  • Compatible with ISO / IEC 16022 (2rd edition 2006-09-15)
  • Completely developed in Java
  • Mature Data Matrix barcode generation Java library used by 2000+ clients
Index
 

Java Barcode Data Matrix Generator Introduction

Java Barcode is a Java barcode generator which generates high quality 1D (linear) and 2D (matrix) barcodes in Java, Jasper Reports, iReport, and Eclipse BIRT projects.

 

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:



 

Java Barcode Data Matrix Generation FAQ?

  1. How to generate barcode Data Matrix in Java class?

    // 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/datamatrix?DATA=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/datamatrix?DATA=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 & print barcode Data Matrix image in Jasper Reports?



    Complete Guide for Barcode Generation in Jasper Reports

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



    Complete Guide for Barcode Generation in iReport

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



    Complete Guide for Barcode Generation in Eclipse BIRT

  8. 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 Class Properties Servlet Properties Default Comments
Basic data DATA "" value to encode
 
Data Matrix
Special
processTilde PROCESS-TILDE false Set the processTilde property to true, if you want use the tilde character "~" to specify special characters in the input data. Default is false.
  • ~3: is used only at the very beginning of the symbol for the reader programming purpose.
  • ~5: 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.
  • ~6: 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.
  • ~NNN: is used to represent the ASCII character with the value of NNN. NNN is from 000 to 255
dataMode DATA-MODE 0 Set the dataMode property.
Valid value is 0 DataMatrix.M_AUTO (default), 1 DataMatrix.M_ASCII, 2 DataMatrix.M_C40,
3 DataMatrix.M_TEXT, 4 DataMatrix.M_X12, 5 DataMatrix.M_EDIFACT, 6 DataMatrix.M_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 Parameter: "DataMode".
formatMode FORMAT-MODE 0 Default is DataMatrix.F_10X10. Specifies the Data Matrix Format to use on that symbology. Valid values see class DataMatrix.F_*x*;
fnc1Mode FNC1MODE IBarcode.FNC1_NONE (0) valid values:
IBarcode.FNC1_NONE (0)
IBarcode.FNC1_ENABLE (1)
applicationIndicator AI 0  
isStructuredAppend STRUCTURE-APPEND false Set isStructuredAppend property to true, then Structured Append is enabled.
symbolCount SYMBOL-COUNT 0 Set symbolCount property to the number of total symbols which make the sequence.
symbolIndex SYMBOL-INDEX 0 Set symbolIndex property to the position of current symbol in the secuence (Start with 0).
fileID FILE-ID 0 Set fileID property to be identified to the same file.
 
Size Related uom UOM 0 Unit of meature for all size related setting in the library.
0: pixel; 1: inch; 2: cm.
X X 2 width of barcode module (narrow bar), default is 2 pixel
barcodeWidth BARCODE-WIDTH 0 generted barcode image width
barcodeHeight BARCODE-HEIGHT 0 generted barcode image height
leftMargin LEFT-MARGIN 0 image left margin
rightMargin RIGHT-MARGIN 0 image right margin
topMargin TOP-MARGIN 0 image top margin
bottomMargin BOTTOM-MARGIN 0 image bottom margin
resolution RESOLUTION 72 in DPI
rotate ROTATE IBarcode.ROTATE_0 (0) valid values:
IBarcode.ROTATE_0 (0),
IBarcode.ROTATE_90 (1),
IBarcode.ROTATE_180 (2),
IBarcode.ROTATE_270 (3)



All Java Barcode Generator Supporting Bar Code Symbology Types



Java Barcode Generator Tutorial