Home  >  Barcode Component Suite for .NET  >  Tutorial on Barcode Creator Integration with C#  >  C#.NET Data Matrix Barcode Generating Control
C#.NET Data Matrix Barcode Generator Component
C#.NET Data Matrix Barcode Generator Component can create, generate Data Matrix barcode via C# class codes in Visual Studio 2005/2008/2010.
Overview - C#.NET Data Matrix Barcode Generator Component
Data Matrix is a two dimensional matrix barcode consisting of black and white "cells" or modules arranged in either a square or rectangular pattern. This C#.NET barcode generating library is used to generate & save Data Matrix barcode images in .NET class application using C# class code.
How to generate Data Matrix barcode images in other .NET application using C# code?
Benefits - Data Matrix C#.NET Barcode Generating Library

Technologies of Data Matrix Barcode C# .NET Creator SDK

Barcode Imaging of Data Matrix Barcode C# .NET Creator Control

View more about Data Matrix Barcode Properties of C#.NET Barcode Generator Library
How to Generate Data Matrix Barcode Using C# Class Code
Following C# Code are used to generate & create Data Matrix barcode in C#.NET applications:
//Create a new Data Matrix barcode object in C#.NET,
DataMatrix barcode = new DataMatrix();

//Encode data into Data Matrix barcode symbology
barcode.CodeText = "Abc1234567";

Choose data mode for generating Data Matrix barcode,
1. Auto mode will automatically match the best data mode for you;
2. ASCII mode encodes data that mainly contains ASCII characters (0-127);
3. C40 mode encodes numeric data and upper case characters;
4. Text mode encodes numeric digits and lower case characters;
5. X12 mode encodes the standard ANSI X12 electronic data interchange characters;
6. EDIFACT mode encodes 63 ASCII values (values from 32 to 94) plus an Unlatch character (binary 011111);
7. Base256 mode encode 8 bit values.
barcode.DataMode = DataMatrixDataMode.ASCII;

Select the format mode to Data Matrix barcode.
If the selected format mode have insufficient space to hold the data,
this barcode engine will select the appropriate format mode automatically
barcode.FormatMode = DataMatrixFormatMode.FM_52X52;

//Enable the option of ProcessTilde when the tilde character "~" is necessary
barcode.ProcessTilde = true;

//Set the Data Matrix barcode graphic measurements as Pixel
barcode.GraphicsUnit = KeepDynamic.Barcode.Generator.GraphicsUnit.Pixel;

//Assign the values of bar width to Data Matrix barcode
barcode.X = 3;

//Set the margins around the Data Matrix barcode symbology
barcode.LeftMargin = 3;
barcode.RightMargin = 3;
barcode.TopMargin = 3;
barcode.BottomMargin = 3;

// Set Data Matrix barcode image size
barcode .BarCodeWidth = 180;
barcode.BarCodeHeight = 180;

Set the resolution of Data Matrix barcode image that is drawn to,
and change the Data Matrix barcode image orientation
barcode.Resolution = 72;
barcode.Rotate = Rotate.Rotate0;

Set Data Matrix barcode drawing image format to PNG in C#
Generate Data Matrix barcode image in C#
barcode.Format = System.Drawing.Imaging.ImageFormat.Png;
barcode.drawBarcode("C://barcode-datamatrix-csharp.png"); // other barcode outputting ways: // output generated barcode to byte array byte[] barcodeInBytes = barcode.drawBarcodeAsBytes(); // output generated barcode to Graphics object Graphics graphics = ...; barcode.drawBarcode(graphics); // output generated barcode to Bitmap object Bitmap barcodeInBitmap = barcode.drawBarcode(); // draw created barcode to HttpResponse object HttpResponse response = ...; barcode.drawBarcode(response); // save generated barcode images to Stream object Stream stream = ...; barcode.drawBarcode(stream);
C#.NET Data Matrix Barcode Generator - Supported Barcode Types