KA.Barcode for .NET Suite
How to Generate, Print Data Matrix in C#.NET
How to Generate 2D Data Matrix Barcode Images Using Visual C# in .NET Applications

C# Data Matrix Barcode Generator Library
Generate, create, render data matrix 2d barcode from string data with free open source c# example. no font









  • Completely compatible with .NET Framework 2.0 and later versions
  • Easy to generate Data Matrix ECC 200 barcodes in Visual C#.NET programming
  • Dynamically generating Data Matrix in ASP.NET, WinForms, Crystal Reports and RDLC Reports
  • Draw Data Matrix barcode images in stream & graphics object and save in multiple image formats
  • Offer various barcode settings for Data Matrix including module width, format mode, margins, etc
  • Puchase royalty-free and permanent license of .NET Data Matrix Barcode Generator Library
C# Data Matrix Barcode Control Description
KA.Barcode for .NET Suite is a mature and reliable barcoding encoder control SDK for generating two-dimensional Data Matrix images in .NET development environment. Developers can easily create and display Data Matrix in ASP.NET web pages, Windows Forms & Crystal Reports with C# programming. Flexible barcode settings are also available for users to customize generated images.
What Is A Data Matrix Barcode
Data Matrix, also named as ECC200, 2D DataMatrix barcode, is a two-dimensional matrix barcode commonly used to mark small items. Being space-efficient, Data Matrix is recommended by American EIA for labeling small electronic components.

Data Matrix in ASP.NET projects

This KeepAutomation barcode encoder dll for .NET also supports Data Matrix barcode generation in ASP.NET web applications. Users can easily create Data Matrix barcodes in Websites, Microsoft IIS as well as Visual C# Class Library & Console applications. Here are more details for you:
How to print barcode in Visual C# with ASP.NET framework web control.
Create barcodes in ASP.NET Core web app using C#
Create barcodes in ASP.NET Core MVC web app using C#

Data Matrix in .NET Windows (Desktop) projects

With KeepAutomation barcode generator for .NET Suite, developers can easily create Data Matrix barcodes in .NET Windows Forms with simple control drag-n-drop or C# class library. For more details or C# sample code, please view
How to create barcode in .NET WinForms with Visual C#.
Generate barcodes in WPF .NET Core using C#




Data Matrix Valid Data Sets
  • All 128 characters of ASCII.

  • Extended ASCII (ISO 8859-1 values 128-255)
Create GS1 Compatible Data Matrix
  • Set FNC1 to KeepAutomation.Barcode.FNC1.First

  • In barcode data setting CodeToEncode, around AI code with "()", and followed by AI data, such as "(02)225(03)33344". Here "02", "03" are the AI code, "225", "33344" is the AI data,




Encode Non-printable Chars in Data Matrix
  • Set TildeEnabled to true

  • Use '~ddd' for non-printable chars. For example, ASCII char [GS] is non-printable, and its decimal value is 29. In barcode data, you need use ~029 for char [GS].




Encode byte[] in Data Matrix
The following C# source codes demo how to encode byte[] object in Data Matrix
//  Byte array to encode
byte[] dataBytes = new byte[] { 0x41, 0x42, 0x43, 0x44, 0x45 };

//  Convert byte array to the input (property CodeToEncode)
String inputMsg = "";
foreach (byte b in dataBytes)
    inputMsg += "~" + b.ToString().PadLeft(3, '0');

//  Create barcode
BarCode barcode = new BarCode();
barcode.Symbology = Symbology.DataMatrix;
barcode.DataMatrixDataMode = DataMatrixDataMode.Base256;
//  enable '~' in the input message
barcode.TildeEnabled = true;
barcode.CodeToEncode = inputMsg;

//  set module size to 5 pixels
barcode.BarcodeUnit = BarcodeUnit.Pixel;
barcode.X = 5;
barcode.Y = 5;

barcode.generateBarcodeToBitmap().Save(@"C:\DataMatrix_Bytes.png");




Encode Japanese (non-English) text in Data Matrix
The following C# source codes demo how to encode non English text (such as Japanese text) in Data Matrix
//  Message in Japanese
String unicodeMsg = @"おはようございます";

//  Convert Unicode string to data bytes
byte[] dataBytes = Encoding.Unicode.GetBytes(unicodeMsg);
//  Convert byte array to the input (property CodeToEncode)
String inputMsg = "";
foreach (byte b in dataBytes)
    inputMsg += "~" + b.ToString().PadLeft(3, '0');

//  Create barcode
BarCode barcode = new BarCode();
barcode.Symbology = Symbology.DataMatrix;
barcode.DataMatrixDataMode = DataMatrixDataMode.Base256;
//  enable '~' in the input message
barcode.TildeEnabled = true;
barcode.CodeToEncode = inputMsg;

//  set module size to 5 pixels
barcode.BarcodeUnit = BarcodeUnit.Pixel;
barcode.X = 5;
barcode.Y = 5;

barcode.generateBarcodeToBitmap().Save(@"C:\DataMatrix_Japanese.png");




Generate Barcode Image in Specified Width and Height
  • Set property AutoSizeAdjust to true

  • Set property DPI to be the same or higher as your printer's resolution

  • Set property BarcodeUnit to inch or cm

  • Set property BarCodeWidth and BarCodeHeight to your required image width and height
Data Matrix Property Settings
Click to view the complete list of properties for Data Matrix generation at Data Matrix generator property list for C#.NET code
Data Matrix Barcode Generation in .NET Applications with C#