.NET Barcode Scanner SDK

Read & Scan Barcode in C#
With simple integration, barcodes can be easily scanned and decoded in your .NET projects from images, like JPG, JPEG, PNG, TIFF, BMP, and GIF. This article will guide you to integrate CnetSDK .NET Barcode Scanner Library DLL into Visual Studio .NET project and tell you how to use barcode scanner in C#. Barcode Scanner C# sample codes for .NET 1D & 2D bar codes recognition and decoding are provided. You can choose suitable .NET barcode scanner APIs to read and scan barcodes from a loaded image source.
.NET BARCODE SCANNER INTEGRATION
We provide free .NET Barcode Scanner SDK trial package for your evaluation. Please firstly download .NET Barcode Scanner online. In the download package, you will find CnetSDK.Barcode.Scanner.Trial.dll. To integrate this barcode scanner library to your Visual C# .NET project. you can simply add CnetSDK.Barcode.Scanner.Trial.dll into your C#.NET project reference.

Please note, the first data value of each barcode will be decoded as a question mark (?) if you are using our free trial package.
.NET BARCODE SCANNER APIS
CnetSDK .NET Barcode Scanner SDK provides multiple .NET APIs for you to choose from. You can use the first group of .NET APIs to scan and read all bar codes from your loaded image source in C# programming. Or you can tell integrated .NET barcode scanner library class what is the barcode type to recognize and decode (see as second group). Moreover, there are three .NET APIs for decoding the only barcode from loaded image. And these .NET APIs can help to improve the accuracy of barcode reading and decoding.​

Our .NET barcode scanner library allows you to load three image source to your C# .NET barcode scanning application, which are String, Stream (memory stream), and Bitmap Object.
// Scan all 1D & 2D barcodes from Bitmap object.​
public static ScanResult[] ScanBarcode(Bitmap Bitmap);

// Scan all 1D & 2D barcodes from Stream object.
public static ScanResult[] ScanBarcode(Stream Stream);

// Scan all 1D & 2D barcodes from image file on the disk.
public static ScanResult[] ScanBarcode(string FileName);
// Decode a certain type of barcode from Bitmap.​​
public static ScanResult[] ScanBarcode(Bitmap Bitmap, CSBarcodeType Type);

// Decode a certain type of barcode from Stream.
public static ScanResult[] ScanBarcode(Stream Stream, CSBarcodeType Type);

// Decode a certain type of barcode from local image file.
public static ScanResult[] ScanBarcode(string FileName, CSBarcodeType Type);
// Scan the only barcode from Bitmap. It improves barcode reading accuracy.
public static ScanResult[] ScanOnlyBarcode(Bitmap Bitmap);

// Scan the only barcode from Stream. It improves barcode reading accuracy.
public static ScanResult[] ScanOnlyBarcode(Stream Stream);

// Scan the only barcode from local image file. It improves barcode recognition accuracy.
public static ScanResult[] ScanOnlyBarcode(string FileName);
.NET BARCODE SCANNER C# SAMPLE CODE
In this section, you will see three pieces of .NET Barcode Scanner C# sample codes for reading and scanning linear/1D & matrix/2D barcodes in your .NET project. You can refer to the first C# sample code to scan, decode and read all barcodes from your image source, linear, 2D, or both. Also, please refer to the second C# sample code to define a certain barcode type to read and recognize. The last C# example illustrates how to read and decode the only barcode from image and this .NET method will improve the accuracy of barcode reading.
C# Example - Read All Barcodes from Bitmap Object


public void ReadAllBarcodeTypesfromImage(Bitmap Bmp)​
       {
              ScanResult[] DecodeBarcode = CSBarcodeScanner.ScanBarcode(Bmp);
              foreach (ScanResult output in DecodeBarcode)
              {
                      Console.WriteLine(output.BarcodeType.ToString() + "-" + output.BarcodeData);
               }
                      Console.ReadKey();
        }
C# Example - Choose A Barcode Type to Read (Sample is Code 39)


public void ReadACertainBarcodeTypefromImage(Bitmap Bmp)
       {
              ScanResult[] DecodeBarcode = CSBarcodeScanner.ScanBarcode(Bmp, CSBarcodeType.Code39);
              foreach (ScanResult output in DecodeBarcode)
              {
                      Console.WriteLine(output.BarcodeData);
               }
                      Console.ReadKey();
        }
C# Example - Read and Decode the Only Barcode from Image


public void ReadtheOnlyBarcodefromImage(Bitmap BarcodeImage)
       {
              Bitmap BarcodeImage = new Bitmap("CnetSDKTest.jpg");
              ScanResult ReadBarcode = CSBarcodeScanner.ScanOnlyBarcode(BarcodeImage);​
              Console.WriteLine("barcode data:{0}.", ReadBarcode.BarcodeData);
              Console.ReadKey();
        }
If you are in need of .NET Barcode Scanenr VB.NET code demo, please refer to How to Scan and Read Barcodes from Image Using VB.NET Code.
SUPPORTED BARCODES

Scan QR Code in C#

Scan Data Matrix in C#

Scan PDF-417 in C#

Scan Aztec in C#

Scan EAN-13 in C#

Scan EAN-8 in C#

Scan UPC-A in C#

Scan UPC-E in C#

Scan Code 128 in C#

Scan Code 39 in C#

Scan Code 93 in C#

Scan Codabar in C#

Scan ITF-14 in C#