Data Matrix Generator Library for .NET in C# Class
How to Generate 2D Data Matrix Barcodes in .NET with C# Programming
100% built in Visual C#, compatible with .NET Framwork 2.0, 3.0, 3.5, 4.0 and later
Run perfectly in many .NET Framework applications, like WinForms and ASP.NET
Create high-quality Data Matrix barcode images with C# codes in .NET
Insert & draw Data Matrix barcodes in Crystal Reports and RDLC Reports
Save generated Data Matrix barcodes as image files without using barcode fonts
Suitable for other linear & 2D barcodes generation, like EAN13, Code 128, QR Code, etc
C# 2D Data Matrix Barcode Introduction
Data Matrix is a 2 dimensional (2D) matrix barcode symbology, with high-density data and strong error correction ability. It has two types-ECC 200 and ECC000-140. In the real daily life, ECC200 is more widely used.
Quick to Create Data Matrix 2D Barcodes using C#
Create a new DataMatrix object
Enter Data Matrix encoding text in property Data
Use method drawBarcode() to generate, print Data Matrix barcode to a PNG image file
Data Matrix 2d barcode supports the following character set, data encoding using C#.
Full 128 ASCII table chars
Unicode text
GS1 Data Matrix
Encode Data Matrix ASCII characters
Full 128 ASCII (American Standard Code for Information Interchange) table includes 95 printable characters (such as Uppercase, Lowercase letters, digits),
and 33 control characters (such as char 'carriage return'), which are not printable.
Creating Data Matrix with printable ASCII chars encoded is really easy. You can directly enter the ASCII chars to property Data.
To create Data Matrix with ASCII control chars (non-printing chars), you need convert each control char to it's ASCII interger value in three digits string, then pass to the property Data
provide control char's ASCII integer value to property Data
Enable property ProcessTilde to true. The C# barcode library will process all 3-digit string following tilde "~".
In property Data, all control chars will be converted to it's ASCII integer value in 3-digit string behind char ~, and they will be inserted to the Data Matrix encoding code
Set property IsUnicodeData to true. The C# Data Matrix Generator library will automatically encode the Unicode text in the property Data to Data Matrix barcode in C# application.
DataMatrixbarcode=newDataMatrix();barcode.Data="你好";// hello in Chinesebarcode.IsUnicodeData=true;barcode.drawBarcode("C://BarcodeLib//csharp-data-matrix-unicode-text.png");
Encode GS1 Data Matrix Barcodes
Set property FNC1Mode to DataMatrixFNC1Mode.FirstPosition. The barcode generation library will encode and print GS1 Data Matrix in C# application.
Data Matrix barcodes usually are in square shapes. To create square Data Matrix, you need only set the barcode image width in property ImageWidth.
The C# source code below will generate Data Matrix with width in 250 pixels, and height in 250 pixels.
DataMatrixEncoding.Base256. Encoding All byte values 0 - 255.
Using BarcodeLib C# Data Matrix Barcode Generator library, we strongly recommend you to choose DataMatrixEncoding.Auto (default value) for
property Encoding. With auto mode, the barcode library will automatically analyze the Data Matrix encoding text and select the suitable combination of the six encoding modes in C# application.
Data Matrix ISO standard specifies 24 square symbols and 6 rectangular symbols available in ECC 200.
Each symbol size includes different rows and columns with different data storage capacity.
Using BarcodeLib C# Barcode library, you can specify the Data Matrix format mode using property FormatMode.
If your encoding Data Matrix data size is larger than your specified Data Matrix format mode, the barcode library will automatically choose the right format mode for you.
Data Matrix barcode ISO standard provides a mechanism for the data in a file to be split into blocks and be represented in multiple Data Matrix barcode symbols.
Set property EnableStructuredAppend to true to enable Data Matrix Structured Append mode
Set property StructuredAppendCount to specify the total number of Data Matrix barcode symbols to store the same data message
Set property StructuredAppendIndex to specify the order of the current data matrix. The first symbol index should be 0. The C# sample code below will create the first Data Matrix symbol.
Set property StructuredAppendFileID with a random unique integer.
All data matrix barcodes to store the same data message should have the same StructuredAppendFileID value.
DataMatrixbarcode=newDataMatrix();barcode.Data="Data Matrix";barcode.EnableStructuredAppend=true;// The whole data message will be stored in three Data Matrix barcodesbarcode.StructuredAppendCount=3;// This Data Matrix symbol is the first onebarcode.StructuredAppendIndex=0;// All three Data Matrix barcodes must have the same file idbarcode.StructuredAppendFileID=999;barcode.drawBarcode("C://BarcodeLib//csharp-data-matrix-structured-append.png");
How to Create Data Matrix in C# ASP.NET web app?
Our C# Data Matrix Barcodes Generator Library also allows users to generate Data Matrix in ASP.NET Web Project. The following are detailed steps:
Add Barcodelib.Barcode.ASP.NET.dll to your web project.
Add Barcodelib.Barcode.ASP.NET.dll to the Toolbox.
Copy files "datamatrix.aspx" & "datamatrix.aspx.cs" from the folder barcode in the downloaded trial package to the folder where your web project is located.
Drag DataMatrixASPNET from the toolbox to the split part of your aspx page, and then change its settings in the Properties window or with above C# source code.
How to Generate Data Matrix in C# WinForms?
You may use our C# Generator DLL to create a Data Matrix image in WinForms Project with following steps:
Add BarcodeLib.Barcode.WinForms.dll from the downloaded trial package to your WinForms Project.
Add BarcodeLib.Barcode.WinForms.dll to your Visual Studio Toolbox.
Drag DataMatrixWinForm to your windows form and a Data Matrix barcode will be produced or you could use above free C# source code to create Data Matrix.