How to create Datamatrix Barcode
This article shows how to
- Create a DataMatrix barcode.
- Setting the encoding mode.
To create a DataMatrix barcode:
- Instantiate a BarcodeGenerator,
- Call the setSymbologyType() method and pass Datamatrix.
- Call setCodeText() method to set the data you want to encode.
You can also pass the CodeText and Symbology type when creating the BarcodeGenerator object:
|Figure: Sample output DataMatrix barcode|
Aspose.BarCode supports several types of an encoding mode for DataMatrix. The default mode is Auto, indicating that the encoder will choose the best mode. The other supported DataMatrix Encode modes are given below:
|Auto||Automatically pick up the best encode mode for Datamatrix encoding|
|ASCII||Encodes one alphanumeric or two numeric characters per byte|
|Full||Encode 8-bit values|
|Custom||Encode with the encoding specified in BarCodeBuilder.CodeTextEncoding|
|C40||Uses C40 encoding. Encodes Upper-case alphanumeric, Lower case and special characters|
|Text||Uses Text encoding. Encodes Lower-case alphanumeric, Upper case and special characters|
What is the best encode mode? The best encoding mode will likely produce the smallest picture under the same settings. What the encoder does is trying to encode 2 characters into one single byte.
The left side barcode was created in Auto encoding mode. The right side barcode uses ASCII encode mode.
|Figure: DataMatrix under different encoding modes|
Custom Encoding Mode
Aspose.BarCode now supports the Custom encoding mode for DataMatrix in order to support Encoding standards like UTF8.
Below is an example of setting up a DataMatrix custom encode mode.