Data Matrix FAQ in C#.NET Barcode Generator DLL

Using C# class method to generate and customize Data Matrix in .NET with barcode control library
Barcode in C# > 2D > Data Matrix FAQ
C# Barcode Library to Generate Barcode Image - Data Matrix FAQ in C#
Data Matrix barcode control library SDK for C#.NET projects is a robust .NET control DLL which supports creating 2D barcode Data Matrix using C# in various .NET environments such as ASP.NET, Windows application, Crystal Report, Reporting Service, class library and console application. C# barcode control SDK creates and delivers Data Matrix barcode on-the-fly as image in gif, tiff, bmp, png or jpeg formats.
This page has detail introduction of Data Matrix property settings in C#.NET projects and provides C# sample code to customize Data Matrix settings from the following aspects:
  • Generate Data Matrix Barcode Images Using C# Class - Data Matrix Data Encoding
  • Generate Data Matrix Barcode Images Using C# Class - Data Matrix Special Settings
  • Generate Data Matrix Barcode Images Using C# Class - Data Matrix Adjustment
  • Generate Data Matrix Barcode Images Using C# Class - Data Matrix Image Customization
  • Generate Data Matrix Barcode Images Using C# Class - Data Matrix Solution Project Support
C# Barcode Control SDK to Generate Barcode Image - Data Matrix Data Encoding
2D Data Matrix Barcode Valid Data
  • Standard ASCII characters: 0-127 including A-Z, a-z, 0-9, and special characters
  • Extended ASCII characters: 128-255
Data Matrix C#.NET Sample Code:
barcode. Symbol = BarcodeSymbol.DataMatrix;
barcode.BarcodeData = "TerrekDataMatrix";
C# Barcode Library DLL to Create Barcode Image - Data Matrix Special Settings
Data Matrix Data Mode
Data Matrix has multiple data modes to encode different types of data including ASCII, C40, Text, X12, EDIFACT and Base 256 in C# class, Terrek has designed "Auto" data mode for easy and quick generation of Data Matrix barcodes. Programmers may change the Data Matrix data mode through DataMatrixDataMode property.
Data Matrix C#.NET Sample Code:
barcode.DataMatrixDataMode = DataMatrixDataMode.Auto(0);
Data Matrix Format Mode
Data Matrix has different format modes size from 10*10 to 144*144 and 8*18 to 16*48 respectively with even number of rows and even number of columns. Developers may change the format mode by using "DataMatrixFormatMode" property.
Data Matrix C#.NET Sample Code:
barcode.FormatMode = DataMatrixFormatMode.Format_10X10 (0);
Data Matrix GS1 Compatible
GS1 system uses Data Matrix as a GS1 barcode because Data Matrix barcode is able to encode GS1 System data structures and offers other technical advantages. Developers may apply this function by setting FNC1 property to FNC1_1(1), which designates data formatted in accordance with the GS1 General Specifications.

Data Matrix C#.NET Sample Code:
barcode. FNC1 = FNC1.FNC1_1(1);
Data Matrix Tilde Function
Terrek.Barcode control component is capable of generating Data Matrix with tilde function, which is able to encode some special characters such as Returns, Tabs, RS, etc in barcode data. To apply specific special characters, programmers need to set the Tilde function to true.
Data Matrix C#.NET Sample Code:
barcode.Tilde = true;
C# Barcode Library DLL to Create Barcode Image - Data Matrix Size Adjustment
Data Matrix UOM (Unit of Measure)
Set property MeasuringUnit for properties BarWidth, BarHeight, MarginL and MarginT. Valid values are PIXEL, CM and INCH. Default is PIXEL. With this UOM setting, users can control the whole barcode size to a unique type.
Data Matrix C#.NET Sample Code:
barcode.MeasuringUnit = MeasuringUnit.CM;
Data Matrix Module Size
Data Matrix bar size refers to the BarWidth and BarHeight of a module bar. When developers need to create barcodes with a fixed bar width, these two properties need to be implemented. With the ImageResize applied, image width & image height are changed according to the customization of bar width and bar height.
Data Matrix C#.NET Sample Code:
barcode.ImageResize = true;
barcode.BarWidth = 3;
barcode.BarHeight =3;
Data Matrix Margin Size
Increasing the width of margins around the symbol is one way to enhance the readability of the Data Matrix barcode image. The barcode control library set the left, right, top, and bottom margins separately with float values. The default value is 0.
Data Matrix C#.NET Sample Code:
barcode. MarginL = 6;
barcode. MarginR = 6;
barcode. MarginT = 6;
barcode. MarginB = 6;
C# Barcode Library DLL to Create Barcode Image - Data Matrix Image Customization
Data Matrix Image Format
Data Matrix is generated as image in C#.NET projects with Terrek.Barcode library SDK. The type is System.Drawing.Imaging.ImageFormat. The valid image format values are Gif, Tiff, Bmp, Png, Jpeg, etc. Please ensure the accordance of image format and suffix of image file name.
Data Matrix C#.NET Sample Code:
barcode.BarcodeFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
barcode.drawBarcode("C:\\datamatrix.jpeg");
Data Matrix Image Resolution
DPI (Dots per inch) is used commonly as the measure of printing resolution. The resolution of image generated by Data Matrix generator could be managed with DPI. The type is int, default value is 96 dpi. Users can change the resolution via DotsPerInch property.
Data Matrix C#.NET Sample Code:
barcode.DotsPerInch = 120;
Data Matrix Image Placement
The created Data Matrix is flexible to change the placement in C#.NET projects. By customizing the BarAlign properly, the image is presented left, right or center in documents or projects. By changing Rotation property, the image can be rotated to 90, 180, and 270 degrees. The default is 0 degree.
Data Matrix C#.NET Sample Code:
barcode.Rotation = Rotation.Degree90;
barcode.BarAlign = BarAlign.Right;
Data Matrix Image Color
It is able to change barcode colors with barcode control library DLL using C#.NET class. Both background color and foreground color are easy to be changed by manipulating ImageColor and BarColor respectively. The default color is white and black.
Data Matrix C#.NET Sample Code:
barcode. ImageColor = Color.White;
barcode. BarColor = Color.Black;
C# Barcode Library DLL to Create Barcode Image - Data Matrix Development Environments
Using C# programming to create Data Matrix images, there are a lot of development platforms can be implemented this barcode solution. See guide to create barcode images in C#.NET projects. And the following projects can be adopted to fulfill your Data Matrix barcode images in .NET projects.
  • Windows Forms Application (design-time and runtime support)
  • Console Application (runtime support)
  • Class Library (runtime support)
  • Windows Service (runtime support)
  • ASP.NET Applications (design-time and runtime support)
  • Web Service (runtime support)
  • Crystal Report for .NET (runtime support)
  • Reporting Service Applications (design-time and runtime support)