Our Customers
Contact Us Email: support@barcodelib.com
Home > .NET Barcode Reader & Scanner > Best Linear & 2D Barcodes Reader & Decoder for C#, .NET Applications
Download Barcode Reader for .NET Trial

How to Scan & Read Barcode Images using C#?

Using free C# code to scan, recognize linear & 2d barcode images in ASP.NET, Windows Forms, WPF, web and desktop applications


  • Complied advanced barcode reading & scanning functions into a mature .NET Barcode Reader Library DLL
  • Effectively run and intalled into Visual Studio .NET 8, .NET 7, 6, 5, .NET Core 3.x, 2.x, & .NET Framework 4.x, 3.x, 2.x
  • Scan and decode common linear & 2d barcode images in VS C#.NET, ASP.NET web form projects
  • Support barcode image recognition in several file formats, such as Jpg, Gif, Png, Bmp, Tiff
  • Use free Visual C# code to scan maximum one barcode per image, page in tiff or pdf document
  • Use free Visual C# code to read partial 1d or 2d barcode image instead of the whole file
  • Mainly decode and read C# Code 39, C# Code 128, C# EAN-13, C# QR-Code, C# Data Matrix, C# PDF-417, ect

Overview

BarcodeLib.com C# Barcode Reader for .NET is a .NET barcode reader component that can recognize linear and 2D barcode images. It can be used in:
  • ASP.NET Website Appliations
  • .NET Windows Forms Appliations
  • .NET, C#, VB.NET Class Library Applications
  • .NET Console Applications
Attention, the first character of barcode data read by the trial package will be a random character.


Install Barcode Reader Library

You can download and install our barcode reader library by using our NuGet packages or by downloading the free trial package from this site.

From NuGet

BarcodeLib C# Barcode Reader library has published several NuGet packages for your various .net development projects. You can install them through the NuGet Package Manager in Visual Studio .NET.

  • BarcodeLib.BarcodeReader.Common : The barcode reader library is built by .NET Standard 2.0. It works for .NET 8, .NET 7, 6, 5, .NET Core 3.1, 2.1, and .NET Framework 4.8. It depends on System.Drawing.Common on Windows system only. Visit it from nuget.org

  • BarcodeLib.BarcodeReader.SkiaSharp : This barcode scanner library is a modified version of BarcodeLib.BarcodeReader.Common. It is using SkiaSharp package instead of System.Drawing.Common. It works for non-Windows systems, such as Linux, MacOS. Visit it from nuget.org

  • BarcodeLib.Barcode.Reader.NET.Framework : This C# barcode reader library is for .NET Framework 4.x, 3.x and 2.x. It supports barcode recognition in C# ASP.NET (.net framework), MVC, WinForms, WPF projects. Visit it from nuget.org

Download from Site

BarcodeLib C# Barcode Reader library is free to download. You can click the following link to download the trial package:
Download C# barcode reader SDK free trial package

Install barcode library DLL to .NET projects


Install on .NET Core apps on Windows Operating System
  • For .NET Core app, add BarcodeLib.BarcodeReader.Common.dll from the downloaded package"/DLL/NET-Standard/" to the .NET project reference.
  • Search and install NuGet package System.Drawing.Common from NuGet Package Manager.

Install on .NET Core apps on Linux, MacOS... (non-Windows Operating System)
  • For .NET Core app, add BarcodeLib.BarcodeReader.SkiaSharp.dll from the downloaded package"/DLL/NET-Standard/" to the .NET project reference.
  • Search and install NuGet package SkiaSharp from NuGet Package Manager.

Install on .NET Framework applications
  • For .NET Framework 4.x application, add BarcodeLib.BarcodeReader.dll from download pacakge "/DLL/NET40/" to the .NET project reference.
  • For .NET Framework 3.x or 2.x application, add BarcodeLib.BarcodeReader.dll from download pacakge "/DLL/NET20/" to the .NET project reference.


Quick to read barcode in C#

Read barcode from image is a simple task. We will take Code 39 amd QR Code barcodes recognition as exsamples. For other linear & 2d barcode scanning, please see C# Linear & 2d Barcode Recogintion Guides.
     string[] results = BarcodeReader.read("c:/code39-barcode.gif", BarcodeReader.CODE39);

string[] results = BarcodeReader.read("c:/qrcode-barcode.gif", BarcodeReader.QRCODE);
These two free C# sample codes will respectively recognize and output all Code 39 and QR Code barcodes in image files "code39-barcode.gif" & "qrcode-barcode.gif".


Advanced barcode scanning using C#


How to quickly scan and recognize a barcode in C#?


If you need to read a large size image, like 4mb per image, you can adjust our C# Barcode Scanner for .NET to imporve barcode recognition speed.
  1. If there is a maximum one barcode per image, page in tiff or pdf document, please set maxOneBarcodePerPage to true.
  2. If maxOneBarcodePerPage is true, our C#.NET Barcode Scanner DLL will immediately stop reading the barcode once detects one barcode.
  3. If maxOneBarcodePerPage is false (default value), our C#.NET Barcode Scanner Library will use total 5 algorithms and each will read the whole image from 4 directions.

How to scan, read barcodes from specified regions in image using C# Barcode Reader?


Besides the above two reading methods, you can still recognize the partial image instead of the whole file.
  1. If the barcode is always located one specified area in the image, you can set and let the library scan that area only. And it will reduce lots of scanning time, CPU and memory usage.
  2. You just only need to specify the left top point and right bottom point of the area (the point X, Y values are expressed in percentage of the whole image, so image most left top point is (0%, 0%), and most right bottom point is (100%, 100%)).
The following Free C# code explains how to recognize top 20% and bottom 20% of a Code 39 barcode image.
     OptimizeSetting setting = new OptimizeSetting();

setting.setMaxOneBarcodePerPage(true);

ScanArea top20 = new ScanArea(new PointF(0.0F, 0.0F), new PointF(100.0F, 20.0F));

ScanArea bottom20 = new ScanArea(new PointF(0.0F, 80.0F), new PointF(100.0F, 100.0F));

List<ScanArea> areas = new List<ScanArea>();
areas.Add(top20);
areas.Add(bottom20);

setting.setAreas(areas);

string[] results = BarcodeReader.read("c:/code39-barcode.gif", BarcodeReader.CODE39, setting);


Parse Complex Scanned Barcode Data in C#


Process GS1 data elements


The GS1 data message is a group of GS1 system element strings. An element string is the combination of a GS1 Application Identifier (AI) and its data field.

Here is a standard GS1 data element string, "(01)99012345678900(400)PO20240516-123(10)ABC123(11)240516".

The following barcode formats support GS1 data encoding:
GS1-128, EAN-13, EAN-8, UPC-A, UPC-E, GS1 QR Code, GS1 Data Matrix, ITF-14.

A sample GS1 Data Matrix barcode image


The C# source code below explains how to read GS1 data elements from the above Data Matrix barcode image using C# barcode reader library.

            string inputFilePath = "C://output//datamatrix-mode-gs1-sample-data.png";

            BarCode[] datas = BarcodeReader.BarcodeReader.ReadBarcode(inputFilePath, BarcodeReader.BarcodeReader.DATAMATRIX);

            Trace.WriteLine("Total Data Matrix 2d barcodes found: " + datas.Length);

            foreach (BarCode barcodeData in datas)
            {
                //  Check whether the barcode is GS1 compatible
                //  This is only for QR Code, Data Matrix, and Code 128
                if (barcodeData.IsGS1Compitable)
                {
                    String dataInString = barcodeData.Data;
                    String dataEncoded = barcodeData.GetMessage();

                    String[] vals = dataEncoded.Split(new char[] { '(', ')' }, StringSplitOptions.RemoveEmptyEntries);
                    for (int i = 0; i < vals.Length; i += 2)
                    {
                        Trace.WriteLine("AI:" +  vals[i] + "; Data field: " + vals[i + 1]);
                    }
                }
            }


View more information here : How to scan, read GS1 barcodes using C# barcode reader library?

Process multiple barcode data in Structured Append mode


Every barcode symbology has maximum number of data to encode. To encode large data message, some barcode symboloy support Structured Append mode.

QR Code and Data Matrix do support encode data with Structured Append mode. You can encode up to 16 QR Code or Data Matrix barcodes to store one data message.

View more information here : How to read barcodes with Structured Append data mode using C#?

Process Unicode text


All of 2D (matrix) barcode symbologies do not support encoding Unicode text directly into barcodes. However most of 2d barcode specifications do support byte array data encoding.

BarcodeLib Barcode Reader for C# library allows you to use one line of code to read, decode Unicode text from 2d barcodes, such as QR Code, Data Matrix and PDF417.

You can view the details here : How to read, parse 2d barcodes with Unicode text using C# barcode reader library?


C#.NET Linear & 2D Barcodes Reading & Scanning Tutorials
Please click each barcode to see its barcode C# reading & scanning tutorial in .NET:
Read C# Linear Barcodes:
Read C# Matrix Barcodes:
All Support Linear Barcode Images: Codabar, Code 39, Code 128, Interleaved 2 of 5, EAN 8, EAN 13, UPC-A, UPC-E.

All Support 2D Barcode Images: Data Matrix, PDF 417, QR Code.
If you need C# barcode generating details, please see:





.NET Barcode Reader, ASP.NET Barcode Reader, C#.NET Barcode Reader, VB.NET Barcode Reader, QR Code .NET Reader, QR Code ASP.NET Reader, QR Code C# Reader, QR Code VB.NET Reader, Data Matrix .NET Reader, Code 128 .NET Reader,Code 39 .NET Reader. .NET Barcode Generator Control, ASP.NET Barcode Generator Control.