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
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.
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.
If there is a maximum one barcode per image, page in tiff or pdf document, please set maxOneBarcodePerPage to true.
If maxOneBarcodePerPage is true, our C#.NET Barcode Scanner DLL will immediately stop reading the barcode once detects one barcode.
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.
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.
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);
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.
stringinputFilePath="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(BarCodebarcodeDataindatas){// Check whether the barcode is GS1 compatible// This is only for QR Code, Data Matrix, and Code 128if(barcodeData.IsGS1Compitable){StringdataInString=barcodeData.Data;StringdataEncoded=barcodeData.GetMessage();String[]vals=dataEncoded.Split(newchar[]{'(',')'},StringSplitOptions.RemoveEmptyEntries);for(inti=0;i<vals.Length;i+=2){Trace.WriteLine("AI:"+vals[i]+"; Data field: "+vals[i+1]);}}}
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.
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.