This short tutorial describes how to read Data Matrix barcode using C#. All the details are present in this article, such as a reference to the library required for developing a Data Matrix code reader in C#, a list of steps, and sample code. A few library options will be discussed to customize the code for fetching information from the Data Matrix image.
Steps for Data Matrix Code Scanner using C#
- Set the environment to use Aspose.BarCode for .NET to read a Data Matrix
- Define the path to the Data Matrix code image file
- Apply a license to read the Data Matrix image, as it requires a license
- Create an instance of the BarCodeReader object by passing the input file name and DecodeType as DataMatrix
- Define the highest quality level to read difficult images
- Scan the image with the defined parameters and get all the barcodes in the image
- Parse through all the barcodes, one at a time
- Print the barcode text, barcode type, and region of the image from where the barcode is read
These steps describe the development of a Data Matrix scanner using C#. Include the required modules from the library, load the license required to read the Data Matrix barcode, and create a BarCodeReader object by setting the input image path and decoding type to DataMatrix. Define the quality level to highest for reading the harder images, read all the barcodes from the loaded image, and display all the barcode data.
Code for Data Matrix Reader using C#
The above sample code demonstrates the process to scan Data Matrix code using C#. Note that if you have multiple Data Matrix codes in the image, you may use preset quality instead of HighQuality. An option is there to set a recognition timeout to avoid hanging, apply checksums to check corrupted images, and use the abort capability for cancelling the long-running scans.
This article explains the process of scanning Data Matrix. To generate Data Matrix code, refer to the article Generate Data Matrix Barcode using C#.