Data Matrix for Java
Barcode Java > Barcode in Java > 2D > Data Matrix

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 prints:
  • all 128 characters of ASCII
  • values 128-255 in accordance with ISO 8859-1. There are referred to as extended ASCII.
Java Data Matrix Barcode Generator - Common Questions

1. How to generate Data Matrix barcodes in JSP & HTML pages?

  1. Copy "barcoding" folder contents to your Java Servlet container like Tomcat or JBoss's applications folder
  2. Restart your Java Servlet container
  3. Open your web browser like IE, Firefox, and navigate to http://localhost:8080/barcoding/datamatrix?DATA=0123456789
  4. To generate Data Matrix barcode images in JSP or HTML pages, insert the following html img tag code:
    <img src="http://localhost:8080/barcoding/datamatrix?DATA=0123456789" border=0 />

2. How to create Data Matrix barcodes in Java Servlet?

        try {
            DataMatrix barcode = new DataMatrix();
            barcode.setCode("Java Data Matrix Barcode Generation");

            response.setHeader("Pragma", "no-cache");
            response.setHeader("Cache-Control", "no-cache");
            response.setDateHeader("Expires", 0);
            ServletOutputStream servletoutputstream = response.getOutputStream();


        } catch (Exception e) {
            throw new ServletException(e);

3. How to generate Data Matrix barcodes in Java Class?

        DataMatrix barcode = new DataMatrix();
        barcode.setCode("Data Matrix in Java");

4. How to draw Data Matrix barcodes to image files?

        DataMatrix barcode = new DataMatrix();
        barcode.setCode("Create Data Matrix in Java");

5. How to draw & print Data Matrix barcodes to Java image objects or stream objects?

        DataMatrix barcode = new DataMatrix();
        barcode.setCode("Java DataMatrix");
        barcode.drawOnGraphics("Graphics2D object");
        barcode.drawOnStream("OutputStream object");
Java Barcode Data Matrix Generator - Data Matrix Property Settings

  • code : Data Matrix encoding data value.

    Servlet Parameter: code; Default Value: ""

  • dataMode : Data Matrix encoding data mode.

    Servlet Parameter: data-mode; Default Value: 0 (MODE_AUTO)

  • formatMode : Data Matrix encoding format mode.

    Servlet Parameter: format-mode; Default Value: 0 (FORMAT_10X10)

  • processTilde

    Servlet Parameter: process-tilde; Default Value: false

  • fnc1Mode

    Servlet Parameter: fnc1-mode; Default Value: 0 (FNC1_NONE)

  • ai : Application Indicator

    Servlet Parameter: ai; Default Value: 0

Barcode Size

  • barcodeUnit : Unit of meature for all size related properties. 0: Pixel (default); 1: CM; 2: Inch.

    Servlet Parameter: barcode-unit; Default Value: 0 (UOM_PIXEL)

  • moduleSize : bar module width & height, default is 3 pixel

    Servlet Parameter: module-size; Default Value: 3.0f

  • leftMargin : generated barcode image left margin

    Servlet Parameter: left-margin; Default Value: 0.0f

  • rightMargin : generated barcode image right margin

    Servlet Parameter: right-margin; Default Value: 0.0f

  • topMargin : generated barcode image top margin

    Servlet Parameter: top-margin; Default Value: 0.0f

  • bottomMargin : generated barcode image bottom margin

    Servlet Parameter: bottom-margin; Default Value: 0.0f

  • resolution : generated data matrix image resolution in dpi

    Servlet Parameter: resolution; Default Value: 72 dpi

  • rotate : barcode data matrix rotate angle, valid values: 0 (ROTATE_0), 1 (ROTATE_90), 2 (ROTATE_180), 3 (ROTATE_270)

    Servlet Parameter: rotate; Default Value: 0 (ANGLE_0)

  • barcodeWidth

    Servlet Parameter: barcode-width; Default Value: 0

  • barcodeHeight

    Servlet Parameter: barcode-height; Default Value: 0

Multiple Data Matrix

  • isStructuredAppend

    Servlet Parameter: structured-append; Default Value: false

  • symbolCount

    Servlet Parameter: symbol-count; Default Value: 0

  • symbolIndex

    Servlet Parameter: symbol-index; Default Value: 0

  • fileID

    Servlet Parameter: file-id; Default Value: 0

Java Barcode Generator Supporting Barcode Symbology Types

Quick Links