C# Barcode Reader Library
How to read barcodes in C# ASP.NET, MVC, Windows applications?


How to C#: Quick to Start Using XImage.Barcode Reader







This C#.NET barcode reading toolkit, RasterEdge XImage.Barcode Reader SDK for .NET is one of the most strongly-featured and mature document imaging library toolkits on the market, which is designed to help developers implement barcode-related tasks in their C#.NET applications.

Using this C#.NET barcode reading control, you can easily and quickly complete both 1d and 2d barcode scanning from images. tiff files, PDF documents, Word documents, Excel files and PPT files in any type of a 32-bit or 64-bit .NET application, including ASP.NET web service and Windows Forms for any .NET Framework version from 2.0 to 4.5.

As you know, there're various reliable barcode reading features that can be implemented in C#.NET programming. And you may want to have a quick testing on RasterEdge XImage.Barcode Reader after downloading its free trial package online. To meet your requirement, on this quick to start page, we will tell how to create a C# console application, and read EAN-13 from PDF in C#.NET.







Download & Install C# Barcode Reader libary into the .NET project



To run the C# source codes in this page, you need download and install the RasterEdge XImage.Barcode Reader C# library. You can view the details here: How to install XImage.Barcode Reader library in the .NET project?



Quick to install from NuGet

For .NET Core apps

PM > Install-Package XImage.BarcodeReader

https://www.nuget.org/packages/XImage.BarcodeReader



For .NET Framework applications

PM > Install-Package XImage.BarcodeReader.Framework

https://www.nuget.org/packages/XImage.BarcodeReader.Framework







Quick to Start: Scan, read barcode in C# application



It is easy to scan, read barcodes from an image file in C# class using XImage.BarcodeReader library. The C# source code below shows how to read Code 39 barcodes from an image file in C# class.

  • Create a ReaderSettings object with barcode format Code 39
  • Scan barcodes using method BarcodeReader.ReadBarcodes() with barcode image file path specified
  • Print all barcodes read from the image

            ReaderSettings setting = new ReaderSettings();
            setting.AddTypesToRead(BarcodeType.Code39);

            Barcode[] barcodes = BarcodeReader.ReadBarcodes(
                setting, new Bitmap("C:/Test-Files/CODE39_DEMO.jpg"));

            foreach (Barcode aBarcode in barcodes)
            {
                Debug.WriteLine(aBarcode.DataString);
            }


After run the C# program, you will get the scanned result "87654321-" from the above barcode image.







How to read multiple barcodes from an image using C#?



XImage C# Barcode Reader library supports reading all barcodes with multiple barcode formats from a single image file in C# code.

The C# code below shows how to scan and recogize all barcodes with Code 128, Code 39 from an image file in C# program.

  • Create a ReaderSettings object with barcode format Code 39 and Code 128 specified
  • Scan barcodes using method BarcodeReader.ReadBarcodes() with barcode image file path specified
  • Print all scanned barcodes with format type and data value from the image

            ReaderSettings setting = new ReaderSettings();
            setting.AddTypesToRead(BarcodeType.Code39);
            setting.AddTypesToRead(BarcodeType.Code128);

            Barcode[] barcodes = BarcodeReader.ReadBarcodes(
                setting, new Bitmap("C:/Test-Files/CODE39_1.png"));

            foreach (Barcode aBarcode in barcodes)
            {
                Debug.WriteLine(aBarcode.Type + ": " + aBarcode.DataString);
            }


After run the C# program, you will get two barcodes with the following information.
Code39: 144
Code39: 601547883G







How to read barcodes from multi-page TIFF file using C#?



To read barcodes from multi-page TIFF file, your project need install RasterEdge C# TIFF library XDoc.TIFF package. It is free. You can install it from nuget.

PM > Install-Package XDoc.TIFF


Now we will show you how to scan and recognize all QR Codes from a TIFF document in C# code.

  • Create a ReaderSettings object with barcode format QR Code specified
  • Load an existing TIFF (.tif) file with barcodes into a new TIFFDocument object
  • Scan barcodes using method BarcodeReader.ReadBarcodes() from the TIFFDocument object
  • Print all scanned barcodes with format type and data value found from the TIFF document

            ReaderSettings settings = new ReaderSettings();
            settings.AddTypesToRead(BarcodeType.QRCode);
           
            TIFFDocument doc = new TIFFDocument("C:/Test-Files/1.tif");
            Barcode[] barcodes = BarcodeReader.ReadBarcodes(settings, doc);

            if (barcodes.Length > 0)
            {
                foreach (Barcode aBarcode in barcodes)
                {
                    Debug.WriteLine(aBarcode.Type + ": " + aBarcode.DataString);
                }
            }
            else
                Debug.WriteLine("[No Barcode Found]");






How to read, recognize barcodes from Adobe PDF document in C#?



Like reading barcode from TIFF file, your project need install RasterEdge C# PDF library XDoc.PDF package. You can download and install it directly from nuget.

PM > Install-Package XDoc.PDF


Now we will guide you how to scan and read all Data Matrix 2d barcodes from an existing PDF document using C#.

  • Create a ReaderSettings object with barcode format Data Matrix specified
  • Load an existing PDF file with barcodes into a new PDFDocument object
  • Scan barcodes using method BarcodeReader.ReadBarcodes() from the PDFDocument object
  • Print all scanned Data Matrix barcodes data values found from the PDF document

            ReaderSettings settings = new ReaderSettings();
            settings.AddTypesToRead(BarcodeType.DataMatrix);

            PDFDocument doc = new PDFDocument("C:/Test-Files/demo.pdf");
            Barcode[] result = BarcodeReader.ReadBarcodes(settings, doc);

            if (result.Length > 0)
            {
                foreach (Barcode barcode in result)
                    Debug.WriteLine("Barcode Data: " + barcode.DataString);
            }
            else
                Debug.WriteLine("[No Barcode Found]");