Generate Data Matrix Code in C#.

Data matrix code offers high data density in a small size which makes it an ideal choice for space-limited scenarios. In some scenarios, you might want to create a Data Matrix code to store information in the form of contrasted cells arranged in a grid. In accordance with such requirements, this article covers how to generate a Data Matrix Code programmatically in C#.

C# API Installation to Generate Data Matrix Code

Aspose.BarCode for .NET API supports generating or scanning different 1D and 2D barcodes. You can configure it in your environment by downloading its DLL files or running the following NuGet command to install it from the NuGet gallery.

PM> Install-Package Aspose.BarCode

Generate Data Matrix Code in C#

You need to follow the steps below to generate a Data Matrix Code:

  1. Create an object of BarcodeGenerator class and set the EncodeType.
  2. Set the pixels and encode mode for the Data Matrix code.
  3. Save the output Data Matrix Code by exporting it as a PNG image.

The following code sample explains how to generate a Data Matrix Code in C#:

Generate Data Matrix ECC200 Code in C#

The following steps demonstrate how to create Data Matrix ECC200 Code in C#.

  1. Instantiate an object of BarcodeGenerator class and pass the input text and EncodeType as parameters.
  2. Set the pixels and data matrix ECC type.
  3. Write the Data Matrix ECC200 Barcode using the Save method.

The code snippet below elaborates on how to generate a Data Matrix ECC200 barcode in C#:

Get a Free License

Interested to evaluate the API without any evaluation limitations? If yes, then you can request a free temporary license.

Conclusion

In this article, you have explored how to generate a Data Matrix Code with different encodings like ECC200, ECC000, ECC050, etc. along with other variations of the data matrix code. You may take a look at other features by visiting the documentation space. Please do not hesitate to get in touch with us at forum in case of any queries.

See Also