GS1- Data Matrix
- 3 minutes to read
Short Description
The GS1 Data Matrix uses a special start combination to differentiate the GS1 DataMatrix symbol from other Data Matrix ECC 200 symbols. This is achieved by using the Function 1 Symbol Character (FNC1) in the first position of the encoded data. It enables scanners to process the information according to the GS1 System Rules.
Bar Code Properties
The type of a bar code control’s Symbology property is DataMatrixGS1Generator.
The following properties are specific to the GS1 DataMatrix type.
-
Gets or sets whether the Module property value should be calculated automatically based upon the barcode’s size.
DataMatrixGS1Generator.FNC1Substitute
Specifies the symbol (or set of symbols) in the bar code’s text that will be replaced with the FNC1 functional character when the bar code’s bars are drawn.
DataMatrixGS1Generator.HumanReadableText
Specifies whether or not parentheses should be included in the bar code’s text.
Examples
The following code creates a GS1- Data Matrix bar code and specifies its main properties.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-add-a-bar-code-to-a-report-e167.
using System;
using System.Collections.Generic;
using System.Drawing.Printing;
using System.Windows.Forms;
using DevExpress.XtraPrinting.BarCode;
using DevExpress.XtraReports.UI;
// ...
public XRBarCode CreateDataMatrixGS1BarCode(string BarCodeText) {
// Create a bar code control.
XRBarCode barCode = new XRBarCode();
// Set the bar code's type to Data Matrix GS1.
barCode.Symbology = new DataMatrixGS1Generator();
// Adjust the bar code's main properties.
barCode.AutoModule = true;
barCode.Text = BarCodeText;
barCode.ShowText = true;
barCode.Width = 200;
barCode.Height = 200;
// Adjust the properties specific to the bar code type.
// (Assigned below are the default values.)
((DataMatrixGS1Generator)barCode.Symbology).FNC1Substitute = "#";
((DataMatrixGS1Generator)barCode.Symbology).HumanReadableText = true;
((DataMatrixGS1Generator)barCode.Symbology).MatrixSize = DataMatrixSize.MatrixAuto;
return barCode;
}
To add the XRBarCode to a report band, handle the report’s XRControl.BeforePrint event.