KA.Barcode Generator for .NET Suite
How to Generate Data Matrix Image in C# Projects
Complete C# source code to generate Data Matrix images in different image formats using Barcode for .NET
  • Reliable barcode maker to easily create, print Data Matrix 2d barcode images in C#.NET class library
  • Draw, paint Data Matrix ECC 200 bar codes in Windows applications, ASP.NET web pages, Crystal Reports, etc
  • Programmatically generate and save Data Matrix pictures locally in Png, Jpeg/Jpg, Gif, Tiff, Bmp image formats
  • Embedding dynamic linear & 2D barcodes, such as QR Code .NET WinForms, Word UPC-E, QR Code ASP.NET, Code 128 Excel, in your applications
  • Support rotating Data Matrix barcode image in 0, 90, 180, or 270 degrees with Visual C#.NET
  • Three units of measure (Pixel, Cm, Inch) to select for easy Data Matrix barcoding
  • Compatible with latest ISO/IEC 16022 Data Matrix barcode specification to ensure readability
  • Resolution adjustable to allow high-quality data matrix tag output for all printers
  • EAN-13 .NET, Interleaved 2 of 5 C#, Data Matrix VB.NET, ASP.NET UPC-E and other linear & 2D barcode control provided
  • User-friendly interface and simple procedure for high-quality Data Matrix encodation and generation in C#
Data Matrix is a bidimensional type also named ECC200, 2D DataMatrix Barcode. KeepAutomation Data Matrix barcode generator add-in is a robust and flexible barcode maker component SDK for generating, creating Data Matrix images in .NET WinForms and ASP.NET web applications using C#.NET class. This page is a guide for Data Matrix image setting in C#. To view data encoding and size setting C# samples, please click the links below:
How to Generate, Specify Data Matrix Barcode Images in C# Class

Installation of KA.Barcode Generator for .NET Suite into C# project

  1. 1.
  2. 2.
    Add Reference: Add "KeepAutomation.Barcode.Window.dll" to your C#.NET project reference.
Copy the following C# Data Matrix assembly to create, render a Data Matrix barcodes.
using KeepAutomation.Barcode.Bean;

BarCode datamatrix= new BarCode();
datamatrix.Symbology = KeepAutomation.Barcode.Symbology.DataMatrix;
datamatrix.CodeToEncode = "C#DataMatrixImage";
datamatrix.X = 3;
datamatrix.Y = 3;
datamatrix.generateBarcodeToImageFile("C:/datamatrix_csharp.png");

Data Matrix X Dimension & Y Dimension

X dimension, the module bar width, is a primary parameter for barcode which stands for the width of the narrowest bar, while Y dimension is the height of the module bar. Since Data Matrix is made up tiny black module squares, you are supposed to set X and Y to the same value.
datamatrix.X = 3;         
datamatrix.Y = 3;

Data Matrix Barcode Margins

Margins are called quiet zones in the barcode specification. The ISO/IEC 16022 specification for Data Matrix requires margins on four sides of a Data Matrix image with the same value of X dimension. For example, if you set X to 3 pixel, then you copy the demo code below:
datamatrix.LeftMargin = 3;
datamatrix.RightMargin = 3;
datamatrix.TopMargin = 3;
datamatrix.BottomMargin = 3;

Produce Data Matrix in Png Image Formats

KA.Barcode Generator for .NET Suite supports printing and saving Data Matrix barcodes in different image formats, including Png, Jpeg/Jpg, Gif, Tiff, Bmp, etc.
datamatrix.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;

Data Matrix Barcode Unit

KA.Barcode Generator for .NET Suite provides three units of measure for Data Matrix image generation: Pixel, Cm and Inch. The default value is Pixel. Copy the demo code below to customize this parameter.
datamatrix.BarcodeUnit = BarcodeUnit.Pixel;

Adjust Data Matrix Image Resolution

KA.Barcode Generator for .NET Suite is designed to help you print high-quality barcode images in C#.NET. You can customize image resolution through DPI, which is short for Dots per Inch. 72 DPI is the default value for the generated Data Matrix barcode images.
datamatrix.DPI = 72;

Data Matrix Image Orientation

In case you want to adjust Data Matrix orientation or image position, i.e. the barcode rotation angle, KA.Barcode Generator for .NET Suite provides four types of barcode orientations for you to choose from: 0 degree, 90 degrees, 180 degrees, and 270 degrees.
datamatrix.Orientation = KeepAutomation.Barcode.Orientation .Degree90

Data Matrix Format Mode

KA.Barcode Generator for .NET Suite supports 40 types of Data Matrix format modes, and the supported formats vary from 10x10 to 144x144. Copy the C# sample code below to adjust it.
datamatrix.DataMatrixFormatMode = DataMatrixFormatMode.FM_12X12;