IDAutomation.com, Inc.
Your Source for Quality Symbology
[IDAutomation.com Home Page]

# DataMatrix Font and Encoder Manual

NOTE: The EVALUATION VERSION of the DataMatrix font and encoder may ONLY be used for testing and evaluation purposes. The use of the evaluation version for purposes other than testing and evaluation is strictly prohibited. In the evaluation version of this product, the text [DEMO] will be added to the beginning of any data encoded.

After you purchase a license to the DataMatrix font, you will receive the fully functional fonts, encoder and font tools that can be printed and scanned without the text [DEMO] included. We offer a 30 day money-back guarantee if you purchase the DataMatrix font and encoder and they do not work in your application.

### Index:

- Using the DataMatrix Encoder for Windows Application
- Barcoding with the ActiveX DLL in Windows
- Barcoding with the DataMatrix Java Class
- Barcoding with Seagate Crystal Reports
- More about Data Matrix
- Font Installation Procedures

#### FAQ - Frequently Asked Questions:

- What files do I need to distribute with my application?

- Why can't I just select the font and type data to create the symbol?

- What are the benefits of printing Data Matrix as a font?

- Can I encode and scan extended characters such as © ® ë ö ?

#### Support Issues and Specifications:

- Data Matrix Formats
- Encoding modes
- Control characters and use of tilde (explains how to encode tab and return functions)

- Line spacing issues (too much space between each line)

- PCL font printing issues

- X axis issues or left margin alignment issues

- Data Matrix Encoder and font specifications

### Barcoding with the Data Matrix Java class:

This section explains the main configuration parameters of the DataMatrix class. This class is a descendant of java.awt.Canvas and you can therefore use it in any java container. You may also wish to review the index of fields and methods.

- fontEncode() - the method that formats and returns a string of data formatted to the Data Matrix Font. See the example below.
- code - this is the value to be encoded.
- encoding - the encoding mode; valid values are E_ASCII (default), E_C40, E_TEXT or E_BASE256. This is explained here.
- preferredFormat - sets the preferred format represented by a number; valid values are from 0 (10X10) to 23 (144X144) and from 24 (8X18) to 29 (16X48); The default value is -1 which sets this to automatic; this is also documented here.
- processTilde (DM_TILDE): if true ("Y") the tilde (~) will be processed as explained here.

#### How to format data to the barcode font using the class.

First of all you have to have a Java 1.1 or greater virtual machine installed on the computer that is to format the data. Copy everything in the "JavaClassRoot" directory to the root directory of your computer's class path. If you don't know what the root is or need assistance in this area, consult the Java documentation or the company you obtained the Java virtual machine from.

After the directories are copied to the class root, the method to format data to the font can then be called from a method in a Java application as in this example:

    import java.io.*;
    import IDautomationDME.*;
    class DMatrixTest
    {
        public static void main ( String [] args )
        {
            String dataToEncode = "Data Matrix Test";
    	DataMatrixEncoder dme=new DataMatrixEncoder();
    	System.out.println( dme.fontEncode(dataToEncode) );
        }
    }

The data string returned by the fontEncode method will create a proper Data Matrix symbol when displayed or printed with the Data Matrix font. To install the font on your operating system consult your OS documentation or follow our font installation procedures.

### Barcoding with the DLL in Windows

Step1: Register the DLL. This can be accomplished automatically by installing the DataMatrix Font Encoder for Windows, an application installation utility or manually. To register the ActiveX DLL manually, perform the following:

Step2: Copy the DLL to the Windows\System directory and register it. To do this, go to the command prompt, change to the Windows\system directory, and type the following command: REGSVR32 "IDAutomationDMATRIX.DLL".

Step3: After registering the DLL, you can reference it from within your application. Refer to your application's documentation to find out how to do this. In MS Office Visual Basic and Visual Basic 6.0 you need to choose Project - References and select the IDAutomationDMATRIX.DLL. Then reference the class and function in your code as in this example:

    	'Get input
    DataToEncode = InputString.Text
    	'Format the Output by calling the DLL
    	'Make sure to add the COM Server DLL to the references!!
    Dim DMFontEncoder As DMATRIXLib.Datamatrix
    Set DMFontEncoder = New Datamatrix
    DMFontEncoder.FontEncode DataToEncode, 0, 0, 0, Printable_string
    	'Printable_string contains the data formatted for the font
    PrintableBarcodeString = Printable_string

A Visual Basic project example is included with the package. These files are placed in the destination directory upon installation.

The following barcode functions are available for the DLL:

DataMatrix ActiveX/COM DLL: IDAutomationDMATRIX.DLL

FontEncode String DataToEncode, Int ProcessTilde, Int EncodingMode, Int PreferredFormat, String Printable_string | The fields that use this function and DataMatrix font must accept returns and multiple lines. Enter zeros for defaults in all integer fields, for example: FontEncode "Test123",0,0,0,Printable_string

- When ProcessTilde is equal to 1, the tilde (~) will be processed as explained here.
- The EncodingMode values are 0 for BASE256, 1 for C40, 2 for TEXT and 3 for ASCII. These modes are explained here.
- PreferredFormat sets the preferred format represented by a Format Number; valid values are from 0 (for automatic) to 23 (144X144) and from 24 (8X18) to 29 (16X48); this is also documented here.

### More about Data Matrix

ECC 200 symbols have an even number of rows and an even number of columns. Most of the symbols are square with sizes from 10 x 10 to 144 x 144. Some symbols however are rectangular with sizes from 8 x 18 to 16 x 48. All ECC 200 symbols can be recognized by the upper right corner module being light (binary 0).

The Data Matrix Encoder supports ECC200 symbols only. ECC200 is the newest version of data matrix and supports advanced encoding error checking and Reed Solomon error correction algorithms. These algorithms allow the recognition of barcodes that are up to 60% damaged.

The package supports two optional mechanisms:

- The "Extended Channel Interpretation" (ECI) mechanism enables characters from other character sets (e.g. Arabic, Cyrillic ..) and other data interpretations or industry-specific requirements to be represented.
- The "Structured append" allows files of data to be represented as a sequence of up to 16 Data Matrix symbols. The original data or file can be reconstructed regardless of the order of the symbols.

The package also supports:

- All sizes and formats (from 10x10 to 144x144).
- ASCII, text , C40 and Base256 (for binary data) encoding.
- The "Extended Channel Interpretation" and Structured append.

### Use With Crystal Reports

This UFL is designed to work with Crystal Reports 6.0 and above; it was created to the Seagate UFL specifications. However, because of a Crystal Reports bug that only allows up to 250 characters to be returned by a formula, you can only encode up to about 70 characters in ASCII mode or 50 characters using BASE256 encoding. Hopefully, Seagate will fix this bug in the next release of Crystal Reports to allow larger Data-Matrix symbols to be created.

After installing the DataMatrix Font and Encoder for Windows, the barcode functions should show up under additional functions in the formula editor. When accessed, our UFL will return a text string that when combined with our DataMatrix font, will produce a DataMatrix barcode. The field where the DataMatrix barcode is to be placed on the report must allow multiple lines because the UFL draws the barcode line by line. Refer to your Crystal Reports documentation for additional information on creating reports with UFLs.

Crystal Reports UFL: CRUFLIDAutomation.dll
Class: FontEncoder (function listed below)
Formula Syntax: =IDAutomationFontEncoderDataMatrix("{Field}",0,0,0 )
Formula Example: =IDAutomationFontEncoderDataMatrix("{@date}+{ORDERS.ORDER_NUM}",0,0,0 )

Crystal Reports DataMatrix UFL Specifics:

=DataMatrix(DataToEncode As String, ProcessTilde As Integer, EncodingMode As Integer, PreferredFormatAs Integer) | The fields that use this function and DataMatrix font must accept returns and multiple lines. Enter zeros for defaults in all integer fields.

### What files do I need to distribute with my application?

If you have purchased a Corporate Distribution License for the Data Matrix Fonts, you may distribute the font files and DLLs with your application. In addition, if you have signed the source code license agreement, you may integrate the source code directly into your application eliminating the need to distribute any DLLs. Remember to have your application register the DLLs after they are copied to the system folder. Redistribution of our fonts and components requires a Corporate Distribution license.

Windows Encoder Files (We recommend using an advanced installation application to distribute files for Windows)
Purpose of File | File to Distribute | Notes
Font File | DMatrix_.TTF | The Data Matrix TrueType font. You may also distribute any other font files in the package as necessary.
Data Matrix DLL | IDAutomationDMATRIX.DLL | This is the encoder DLL that formats the Data Matrix font. It can be found in the system directory after installation. Because it was created with C++ using ATL, it is small and has no dependencies.
Java Encoder Files
Purpose of File | Files to Distribute | Notes
Data Matrix Java Class Library | DataMatrixEncoder.class DataMatrixEncoder$1.class DataMatrixEncoder$charPlacer.class reed.class | These files must exist in the IDautomationDME directory from the class path because IDautomationDME is the package name.
Font File | <depends on OS> | Our PCL and PostScript fonts are commonly used on UNIX systems.
Crystal Reports UFL Encoder Files (We recommend using an advanced installation application to distribute files for Windows)
Purpose of File | File to Distribute | Notes
Font File | DMatrix_.TTF | The Data Matrix TrueType font. You may also distribute any other font files in the package as necessary.
Data Matrix DLL | IDAutomationDMATRIX.DLL | This is the encoder DLL that formats the Data Matrix font. It can be found in the system directory after installation.
VB Runtime DLL | msvbvm60.dll | This runtime file already exists on most PCs and it is required for the Crystal UFL. It can be found in the system directory after installation.
Crystal UFL | CRUFLIDAutomation.dll | The IDAutomation Crystal UFL. It can be found in the system directory after installation.

Data Matrix FAQ (Frequently Asked Questions)

#### If Data Matrix is implemented as a font, why can't I just select the font and type data to create the symbol?

The implementation of Data Matrix as a font consists of both the encoder and the font. The purpose of the encoder is to convert the data to encode into proper bar and space patterns formatted to our Data Matrix barcode font. It is necessary to use the encoder because of the complexity of the symbology and the required Reed Solomon error correction would take a person hours to calculate manually.

#### What are the benefits of printing Data Matrix as a font?

The benefits include high scalability with operating system, application and printer independence, these are best described in our Font Quality Statement.

Can I encode and scan extended characters such as © ® ë or ö ?

The answer is yes! It is possible to scan and encode extended characters provided you do the following:

1. Encode the data using BASE256. This option encodes ASCII 0 to 255 of the ASCII character set.
2. Scan the data via the serial interface option (data bits have to be 8N) on your scanner. Normally, keyboard wedges and USB scanners do not support extended characters above ASCII 128 and they only can scan characters that are actually on the keyboard. Contact your scanner vendor for more information on how to do this; you may have to modify some settings internal to your scanner.

Data Matrix Support and Specifications

### Data Matrix Formats

The Data Matrix Java Package supports all data matrix formats. The following table contains the size, the capacity and the correction error features of each format:

Format Number | Size | Numeric Capacity | Alphanumeric capacity | Binary capacity | Max Correctable Error/Erasure
0 | 10 x 10 | 6 | 3 | 1 | 2
1 | 12 x 12 | 10 | 6 | 3 | 3
2 | 14 x 14 | 16 | 10 | 6 | 5/7
3 | 16 x 16 | 24 | 16 | 10 | 6/9
4 | 18 x 18 | 36 | 25 | 16 | 7/11
5 | 20 x 20 | 44 | 31 | 20 | 9/15
6 | 22 x 22 | 60 | 43 | 28 | 10/17
7 | 24 x 24 | 72 | 52 | 34 | 12/21
8 | 26 x 26 | 88 | 64 | 42 | 14/25
9 | 32 x 32 | 124 | 91 | 60 | 18/33
10 | 36 x 36 | 172 | 127 | 84 | 21/39
11 | 40 x 40 | 228 | 169 | 112 | 24/45
12 | 44 x 44 | 288 | 214 | 142 | 28/53
13 | 48 x 48 | 348 | 259 | 172 | 34/65
14 | 52 x 52 | 408 | 304 | 202 | 42/78
15 | 64 x 64 | 560 | 418 | 278 | 56/106
16 | 72 x 72 | 736 | 550 | 366 | 72/132
17 | 80 x 80 | 912 | 682 | 454 | 96/180
18 | 88 x 88 | 1152 | 862 | 574 | 112/212
19 | 96 x 96 | 1392 | 1042 | 694 | 136/260
20 | 104 x 104 | 1632 | 1222 | 814 | 168/318
21 | 120 x 120 | 2100 | 1573 | 1048 | 204/390
22 | 132 x 132 | 2608 | 1954 | 1302 | 248/472
23 | 144 x 144 | 3116 | 2335 | 1556 | 310/590
24 | 8 x 18 | 10 | 6 | 3 | 3
25 | 8 x 32 | 20 | 13 | 8 | 5
26 | 12 x 26 | 32 | 22 | 14 | 7/11
27 | 12 x 36 | 44 | 31 | 20 | 9/15
28 | 16 x 36 | 64 | 46 | 30 | 12/21
29 | 16 x 48 | 98 | 72 | 47 | 14/25

### Encoding Modes

The data represented in the symbol is can be compressed using one or several of the following algorithms:

- ASCII is used to encode data that mainly contains ASCII characters (0-127). It encodes one alphanumeric or two numeric characters per byte.
- C40 is used to encode data that mainly contains numeric and upper case characters. C40 encodes three alphanumeric data characters into two bytes.
- TEXT is used to encode data that mainly contains numeric and lowercase characters. TEXT encodes three alphanumeric data characters into two bytes.
- BASE256 is used to encode 8 bit values.

All encoding systems can be used to encode any data, however, encoding binary data with C40 generates much more overhead (a larger symbol) than with BASE256.

### Control characters and use of the tilde

The Data Matrix Font Encoder uses the tilde character "~" to recognize some special characters in the input data. The following possibilities are available:

- ~X: Is used to represent ASCII character values from 0 to 26. Replace the X like in the following example ~@ = means character ASCII 0, ~A= means ASCII 1, ~B=means ASCII 2, ~C=means ASCII 3 and so on. The most used symbols are ~I for a tab and ~M which is a return function. These are useful when encoding multiple fields in a single symbol.
- ~1: Represents the character FNC1. When FNC1 appears in the first position (or in the fifth position of the first symbol of a Structured Append), it will indicate that the data conforms to the UCC/EAN Application Identifier standard format.
- ~2: It is used to represent Structured Append. Structured Append is used to link information from several symbols in a sequence. The ~2 must be followed by 3 additional bytes. The first 4 bits of the first byte identify the position of the particular symbol in the sequence. The last 4 bits identify the total number of symbols in the sequence. The second and third byte are used as a file identifier are can have a value between 1 and 254 (up to 254*254=64516 identifiers). See the Data Matrix Specification for more information about this (ISO 16022).
- ~3: This character are only allowed in the first position of the symbol. It indicates that the data contains commands for the barcode reader.
- ~4: Not allowed.
- ~5 and ~6: These characters are only allowed in the first position of the symbol. If ~5 is used the header [)> ascii30 ascii05 ascii29 will be transmitted by the barcode reader before the data in the symbol and the trailer ascii30 ascii04 will be transmitted after the data. If a ~6 is used , the header [)> ascii30 ascii05 ascii29 will be transmitted by the reader before the data and the trailer ascii30 ascii04 will be transmitted afterwards.
- ~7NNNNNN: Specifies the Extended Channel to be used, where NNNNNN is a value between and 000000 - 999999. For example: ~7000010 means Extended Channel 10. Extended channel is used for using other character sets other than ASCII. See the Data Matrix Specification for more information about this (ISO 16022).
- ~dNNN: Represents the ASCII character encoded by the 3 digits NNN. For exmaple, ~d065 represents the character 'A'.

### Line Spacing Issues (too much space between each line)

Some implementations of PostScript fonts can cause a small space to appear between rows in the symbol. The only way to overcome this issue is to make sure your printing application is not adding additional line feeds or in the case of PCL fonts, change the vertical motion index as indicated below. This space will not cause problems with scanners and the barcode will still be readable.

When using 12 or 14 point PCL fonts, an adjustment to the vertical motion index is not usually necessary. However, if you are using other sizes, you may need to adjust it to close the gap between rows. To set the vertical motion index, issue the command before printing with the Data Matrix font. The code for the vertical motion index Command is escape "<Ec>" + "&" + lowercase L "l" + Number Index + Capital "C". Use the chart below below to find the command for your font size. The number may be adjusted as necessary for your printer.

PCL Font Point Size | Vertical Motion Index Command to Use
10 | <Ec> &l6.5C
8 | <Ec> &l5.2C
6 | <Ec> &l3.9C

In the example above, the <Ec> represents the escape character for your software. In DOS Edit, Ec is represented by holding down the CTRL key and pressing the letter P, Releasing both keys and then press the ESC key.

### X Axis Issues or Left Margin Alignment Issues

This issue may exist if you try to move the barcode to the right on the X axis using a programming language such as Visual Basic. When using the printer.currentX specification to set the X axis, only the first line of the barcode would print in the new position and the remaining lines would print at zero (all the way to the left). This is because the printer.currentX specification is reset every time a return is performed. A return must be performed to print the font on the new line

The best solution to this problem would be to find a command that could move the left margin so that returns will return the insertion point to the correct position. Since Visual Basic does not have a command like this a small piece of code must be written to set the currentX for each line.

Step 1. Declare and initialize a variable with the desired X position. Example: my_x = printer.currentX
Step 2. Replace the "Printer.Print OutputString" command with something similar to the following....

    For i = 1 To Len(Output)
       out1 = out1 & Mid(Output, i, 1)
          If Mid(Output, i, 1) = Chr(10) Then
             out1 = Replace(out1, Chr(10), "")
             out1 = Replace(out1, Chr(13), "")
             Printer.CurrentX = my_x
             Printer.Print out1
             out1 = ""
          End If
    Next i

Data Matrix Font / Encoder Specifications:

Data Encoding Modes | ASCII, C40, Text and Base 256.

Module Sizes Supported Square: 10 x 10 to 144 x 144
Rectangular: 8 x 18 to 16 x 48

Font Point Size:

Approximate X dimensions for Data Matrix

14 .122 CM .048 "
12 .105 CM .041 "
10 .086 CM .033 "
8 .061 CM .024 "
6 .052 CM .020 "
4 .031 CM .013 "
3 .026 CM .010 "
2 .017 CM .006 "

Copyright © IDAutomation.com, Inc. 2000-2001. All trademarks mentioned are the property of their respective owners.