Data Matrix Barcode Property Settings





Data Matrix Property Settings


Barcode 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
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
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
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
URL: FNC1MODE
Type: int

Default: IBarcode.
FNC1_NONE (0)
To encode GS1 compatible Data Matrix barcide, you need set fnc1Mode value to IBarcode.FNC1_ENABLE (1).
Property: structuredAppend
URL: STRUCTURED-APPEND
Type: boolean
Default: false
Set StructuredAppend property to true, then Structured Append is enabled.
Property: symbolCount
URL: SYMBOLE-COUNT
Type: int
Default: 0
Set SymbolCount property to the number of total symbols which make the sequence.
Property: symbolIndex
URL: SYMBOL-INDEX
Type: int
Default: 0
Set SymbolIndex property to the position of current symbol in the secuence (Start with 0).
Property: fileId
URL: FILE-ID
Type: int
Default: 0
Set FileId property to be identified to the same file.
 
Barcode
Size
Related
Property: uom
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
URL: X
Type: float
Default: 3
Barcode bar module width and height, default is 3 pixel
Property: barcodeWidth
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
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
URL: LEFT-MARGIN
Type: float
Default: 0
Barcode image left margin size.
Property: rightMargin
URL: RIGHT-MARGIN
Type: float
Default: 0
Barcode image right margin size.
Property: topMargin
URL: TOP-MARGIN
Type: float
Default: 0
Barcode image top margin size.
Property: bottomMargin
URL: BOTTOM-MARGIN
Type: float
Default: 0
Barcode image bottom margin size.
Property: resolution
URL: RESOLUTION
Type: int
Default: 72
Barcode image resolution in DPI (Dots per inch).
Property: rotate
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)
 
In WebStream query string, please use int value for Enums, "true" and "false" for bool.
 

Data Matrix Properties in the Java Program

Generating barcode Data Matrix in Java Class example

	DataMatrix barcode = new DataMatrix();
	
	/*
	   Data Matrix Valid data char set:
	            ASCII values 0 - 127 in accordance with the US national version of ISO/IEC 646
	            ASCII values 128 - 255 in accordance with ISO 8859-1. These are referred to as extended ASCII.
	*/
	barcode.setData("112233445566");
	
	barcode.setDataMode(DataMatrix.M_AUTO);
	
	// if your selected format mode doesnot have enough space to encode your data,
	// the library will choose the right format mode for you automatically.
	barcode.setFormatMode(DataMatrix.F_10X10);
	
	//  Set the processTilde property to true, if you want use the tilde character "~" 
	//  to specify special characters in the input data. Default is false.
	//
	//  1) 1-byte character: ~0dd/~1dd/~2dd (character value from 000 ~ 255); ASCII character '~' is presented by ~126
	//         Strings from "~256" to "~299" are unused
	//       modified to FS, GS, RS and US respectively.
	//  2) 2-byte character (Unicode): ~6ddddd (character value from 00000 ~ 65535)
	//         Strings from "~665536" to "~699999" are unused
	//  3) for GS1 AI Code: 
	//         ~ai2: AI with 2 digits
	//         ~ai3: AI with 3 digits
	//         ~ai4: AI with 4 digits
	//         ~ai5: AI with 5 digits
	//         ~ai6: AI with 6 digits
	//         ~ai7: AI with 7 digits
	//  4) ECI: ~7dddddd (valid value of dddddd from 000000 to 999999)
	//  5) ~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".
	//  6) ~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".
	//  7) ~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".
	barcode.setProcessTilde(true);
	
	// Unit of Measure, pixel, cm, or inch
	barcode.setUom(IBarcode.UOM_PIXEL);
	// barcode bar module width (X) in pixel
	barcode.setX(3f);
	
	barcode.setLeftMargin(0f);
	barcode.setRightMargin(0f);
	barcode.setTopMargin(0f);
	barcode.setBottomMargin(0f);
	// barcode image resolution in dpi
	barcode.setResolution(72);
	
	/*
	  to save into gif file, file name end with .gif
	  to save into jpeg file, file name end with .jpg
	  to save into eps file, call method drawBarcode2EPS and file name end with .eps
	*/
	barcode.drawBarcode("C:\\datamatrix.gif");



 

How to encode 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.




Barcode Types