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
How to quickly scan and recognize a barcode in C#?
If you need to scan a large size image file, like 4mb per image, and there is only one barcode inside the image file, you can improve the barcode reading speed by the following option applied.
When the MaxOneBarcodePerPage option is true, once the barcode reader library recognizes a barcode, it will immediately stop scanning the remaining image areas.
How to scan, read barcodes from specified regions in image?
In addition to full‑image scanning, the library offers partial‑area scanning to increase reading speed.
The C# source code below explains how to scan top 20% and bottom 20% of the image area during barcode scanning.
It will reduce lots of image scanning time, CPU and memory usage.
To define the scanning region, just provide the top‑left and bottom‑right anchor points. Each coordinate is a percentage of the image's total width and height. Thus (0%, 0%) marks the top‑left corner, while (100%, 100%) marks the bottom‑right corner of the whole image.
How to scan, read barcodes from specified directions in image?
The C# barcode library allows you to direct barcode scanning along specific axes. This behavior is configured within the OptimizeSetting class by setting the setReadDirectionOrder() method. You can choose one direction or multiple directions to scan the barcode image.
The enumeration provides the following directional modes:
BarcodeReader.DIRECTION_LEFT_TO_RIGHT. Scan the image from the left side toward the right.
BarcodeReader.DIRECTION_TOP_TO_BOTTOM. Scan the image from the top downward.
BarcodeReader.DIRECTION_RIGHT_TO_LEFT. Scan the image from the right side toward the left.
BarcodeReader.DIRECTION_BOTTOM_TO_TOP. Scan the image from the bottom upward.
The following C# code sample demonstrates how to read a Code 128 barcode image using all four scanning directions.
Note: By default, the barcode reader library will scan a barcode image using all four scanning directions.
Apply barcode image sampling step in C#
When the C# barcode reader library processes a raster image file, it scans the pixel data row by row. You can control the scanning granularity by adjusting the ReadOncePerRowsCount property found in the OptimizeSetting class.
Call method setReadOncePerRowsCount(). Define the scanning step size, i.e., how many lines are advanced between each scanned line.
The minimum value is 1, which means every line is scanned.
The default value is 5 (scanning one line out of every five).
Next, we'll take the C# sample code provided above and update the scan options with the following code snippet.
setting.setReadOncePerRowsCount(5);
Improve barcode recognition ratio by zooming the image
Sometimes zooming a barcode image will improve barcode recognition rates, because it provides the barcode decoder with a more detailed and information‑rich image, transforming a blurry or indistinct barcode into data that the algorithm can reliably interpret.
The following C# demo codes explain how to apply image zooming using C# Barcode Scanner library. Here we will try to zoom the image to 150% of its original size.
ASCII table includes 128 characters. 95 printable characters and 33 control characters (non-printing chars).
ASCII control characters range from 0x00 to 0x1F, plus 0x7F. They have no visible printable symbols. Direct output causes garbled text, requiring dedicated methods to convert them into visual markers.
The following Barcode Formats ASCII characters encoding and decoding.
QR Code
Data Matrix
PDF417
Code 128
Code 39 (extension mode only)
BarcodeLib C# Barcode Reader library provides methods to visualize ASCII control characters.
Call method GetMessageInASCII to print barcode encoding ASCII control characters using library pre-defined labels.
The following image contains two barcodes (Code 128, and Code 39 extension). Both of them are encoding one ASCII control character carriage return.
The barcode reader library will decode the barcode text string and print the control char using pre-defined label [CR] in C# program.
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 GS1 barcode image using C# barcode reader library.
In the scanned barcode information BarCode object, use property IsGS1Compitable to indentity whether it is a GS1 barcode or normal ISO barcode.
This property is working for:
Code 128 (GS1-128), Data Matrix, and QR Code.
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.
Call method GetMessage to decode Unicode text string from 2d barcodes directly.