In the previous article, you have learned how to generate various types of barcodes programmatically. In this article, you will learn how to read the barcodes using C# barcode reader API. The article will also cover how to read particular or different types of barcode symbologies in an image.
- C# Barcode Reader API
- Read Barcodes using C#
- Scan and Read a Particular Barcode Symbology in C#
- Multiple Barcode Symbologies in a Single Image
C# API to Read Barcodes
Aspose.BarCode for .NET provides a powerful barcode scanner and reader API that lets you read a variety of barcode symbologies within a few lines of code. You can either download the API or install it within your .NET application using NuGet.
PM> Install-Package Aspose.BarCode
Read Barcodes using C#
The following are the steps to read a 1D or 2D barcode from an image file.
- Create an object of BarCodeReader class and specify the image’s file path.
- Use BarCodeResult class to fetch the recognition results from BarCodeReader.ReadBarCodes() method.
- Retrieve barcode’s type and text from BarCodeResult object.
The following code sample shows how to read a barcode using C#.
Read a Particular Barcode Symbology in C#
There could be the case when you already know about the symbology of the barcode you are going to read. In such situations, you can provide the barcode’s type to the BarCodeReader’s object. Knowing the type beforehand speeds up the barcode recognition process. The following code sample shows how to specify the barcode’s type.
Scan Multiple Barcode Symbologies in a Single Image
In particular cases, you might have multiple barcode symbologies placed in a single image. For such a case, you can configure the API to recognize all the barcodes in one go. The following are the steps to read multiple barcodes in a single image.
- Create an array of BaseDecodeType to contain the list of barcode symbologies.
- Create an object of the BarCodeReader class and load the image.
- Read barcodes using BarCodeReader.ReadBarCodes() and extract their type and text.
The following code sample shows how to read multiple barcode symbologies in a single image using C#.
In this article, you have learned how to read barcodes programmatically using C#. In addition, you have seen how to read one or multiple barcode symbologies in a single image. You can learn more about C# barcode reader API using the documentation.