Test in production without watermarks.
Works wherever you need it to.
Get 30 days of fully functional product.
Have it up and running in minutes.
Full access to our support engineering team during your product trial
A barcode is a type of label that encodes information about the item to which it is attached. It starts with a pattern of black bars and spaces, typically quite wide, which represent numbers. Barcodes simplify the process of data collection and analysis that is usually time-consuming and difficult. They can be scanned quickly and easily by a machine, which reduces errors and lowers costs. Some of their applications include inventory management, quality control, and supply chain management. For these cases, they have shown to be effective tools in differentiating product levels or tracking products over long distances until their final destination.
There are two coding systems that are used in conjunction with barcodes. These are called the Uniform Code Council (UPC) and the International Standards Organization (ISO). The UPC codes were designed to provide a representation of articles or products sold in retail outlets. The UPC is a 12-digit code that is broken down into 6, 10, or 13 digits. There are also 2 trailing check digits that are used for error correction purposes. When scanned, the first five digits represent the company for which it was manufactured and the product within that company's line. The last number identifies the specific product or article being scanned by its machine-readable barcode. The ISO code was originally developed by companies who trade internationally, and primarily as a representation of an article number instead of an article itself.
In this article, we are going to compare two popular barcode libraries:
Both libraries can be used for the generation and recognition of barcodes. They offer support for all dot net frameworks and allow you to save the barcode images.
BarcodeReader
C# classBarcodelib for .NET is a suite of .NET barcode generator components designed for barcode generation in ASP.NET, .NET class, Console applications, Windows Forms applications, Microsoft Reporting Service, Crystal Reports for .NET, and Client RDlC Reports.
IronBarcode for .NET allows programmers to read and write barcodes and QR codes from within .NET apps and websites. IronBarcode simply requires a single line of code to read or write barcodes. Most barcode and QR standards can be read and written using the .NET barcode library. Code 39/93/128, UPC A/E, EAN 8/13, ITF, RSS 14 / Expanded, Databar, Codabar, Aztec, Data Matrix, MaxiCode, PDF417, MSI, Plessey, USPS, and QR are some of the most common types. Type, text, binary data, page, and picture files are all included in the barcode result data. The Barcode API features are below:
Open Visual Studio and then go to the file menu. Select new project, and then select Console Application/Windows Forms/WPF Application. IronBarcode can be used on all types of applications. Also, you can use apps such as Webform/MVC/MVC Core.
Enter the project name and select the file path in the appropriate text box. Then, click the create button and select the required .NET Framework. The project will now be generated with the structure for the selected application, and, if you have selected the console application, it will open the program.cs file where you can enter the code and build/run the application.
The IronBarcode Library can be downloaded and installed in four ways:
These are:
The Visual Studio software provides the NuGet Package Manager option to install the package directly to the solution. The below screenshot shows how to open the NuGet Package Manager.
It provides the search box to show the list of the packages from the NuGet website. In the package manager, we need to search for the keyword "Barcode", as in the screenshot below:
From the above image, we will get the list of the related search results. We need to select the required option to install the package to the solution.
In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console
Enter the following line in the console tab:
Install-Package BarCode
Now the package will download/install to the current project and be ready to use.
The third way is to download the package directly from the website.
Click the link to download the latest package from the website. After the download, follow the steps below to add the package to the project:
The first thing we need to do is install the IronBarcode library, adding barcode functionality to the .NET framework. We can do this using our NuGet package or by downloading the .NET Barcode DLL.
Install-Package BarCode
The BarcodeLib library can be downloaded and installed in four different ways.
These are:
This method is similar to that used above for IronBarcode. The only thing we need to change is the search criteria, as in the image below.
Select the first option, which will then download the BarcodeLib barcode library.
In Visual Studio, go to Tools -> NuGet Package Manager -> Package Manager Console
Enter the following line in the package manager console tab:
Install-Package BarcodeLib
The package will now download/install in the current project and be ready to use.
The third way is to download the package directly from the website.
Barcode generation can easily be done using IronBarcode and BarcodeLib. Let's take a look at that using an example.
IronBarcode can be used to create a barcode label and then saved into different types of image formats. Also, we can pass the barcode type which we need to generate. The following snippet is for barcode generation.
// Generate a barcode with IronBarcode and save it as an image
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);
// Add annotations below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");
// Save the barcode image in a specified format
MyBarCode.SaveAsImage("MyBarCode.jpeg");
// Generate a barcode with IronBarcode and save it as an image
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);
// Add annotations below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");
// Save the barcode image in a specified format
MyBarCode.SaveAsImage("MyBarCode.jpeg");
' Generate a barcode with IronBarcode and save it as an image
Dim MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128)
' Add annotations below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456")
' Save the barcode image in a specified format
MyBarCode.SaveAsImage("MyBarCode.jpeg")
BarcodeWriter.CreateBarcode
is a static class method from the IronBarcode namespace. It initializes a new barcode object specifying the content and encoding type. We can further specify height and width options. The AddAnnotationTextBelowBarcode
method allows adding text under the barcode.
The above snippet also demonstrates saving the barcode in a JPEG format. IronBarcode offers alternative options like outputting the barcode in HTML, and other image formats for flexibility.
// Create a QR code with a logo
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);
// Change the barcode color
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
// Save the QR code with the logo as a JPEG
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
// Create a QR code with a logo
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);
// Change the barcode color
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
// Save the QR code with the logo as a JPEG
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
' Create a QR code with a logo
Dim QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500)
' Change the barcode color
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)
' Save the QR code with the logo as a JPEG
QRWithLogo.SaveAsJpeg("Logoqr.jpeg")
The snippet demonstrates generating a QR code with an embedded logo and customizing appearance using methods like CreateQrCodeWithLogo
and ChangeBarCodeColor
.
BarcodeLib provides functionality for different barcode types. The following snippet demonstrates its usage:
// Create a barcode using BarcodeLib
BarcodeLib.Barcode.Linear barcode = new BarcodeLib.Barcode.Linear();
// Set barcode parameters
barcode.Type = BarcodeType.CODE39;
barcode.Data = "CODE39";
barcode.UOM = UnitOfMeasure.PIXEL;
barcode.BarWidth = 1;
barcode.BarHeight = 80;
barcode.LeftMargin = 5;
barcode.RightMargin = 5;
barcode.TopMargin = 5;
barcode.BottomMargin = 5;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
// Save barcode image
barcode.drawBarcode("C://barcode.png");
// Additional ways to output the barcode
byte[] barcodeInBytes = barcode.drawBarcodeAsBytes();
Graphics graphics = ...;
barcode.drawBarcode(graphics);
Bitmap barcodeInBitmap = barcode.drawBarcode();
HttpResponse response = ...;
barcode.drawBarcode(response);
Stream stream = ...;
barcode.drawBarcode(stream);
// Create a barcode using BarcodeLib
BarcodeLib.Barcode.Linear barcode = new BarcodeLib.Barcode.Linear();
// Set barcode parameters
barcode.Type = BarcodeType.CODE39;
barcode.Data = "CODE39";
barcode.UOM = UnitOfMeasure.PIXEL;
barcode.BarWidth = 1;
barcode.BarHeight = 80;
barcode.LeftMargin = 5;
barcode.RightMargin = 5;
barcode.TopMargin = 5;
barcode.BottomMargin = 5;
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
// Save barcode image
barcode.drawBarcode("C://barcode.png");
// Additional ways to output the barcode
byte[] barcodeInBytes = barcode.drawBarcodeAsBytes();
Graphics graphics = ...;
barcode.drawBarcode(graphics);
Bitmap barcodeInBitmap = barcode.drawBarcode();
HttpResponse response = ...;
barcode.drawBarcode(response);
Stream stream = ...;
barcode.drawBarcode(stream);
' Create a barcode using BarcodeLib
Dim barcode As New BarcodeLib.Barcode.Linear()
' Set barcode parameters
barcode.Type = BarcodeType.CODE39
barcode.Data = "CODE39"
barcode.UOM = UnitOfMeasure.PIXEL
barcode.BarWidth = 1
barcode.BarHeight = 80
barcode.LeftMargin = 5
barcode.RightMargin = 5
barcode.TopMargin = 5
barcode.BottomMargin = 5
barcode.ImageFormat = System.Drawing.Imaging.ImageFormat.Png
' Save barcode image
barcode.drawBarcode("C://barcode.png")
' Additional ways to output the barcode
Dim barcodeInBytes() As Byte = barcode.drawBarcodeAsBytes()
Dim graphics As Graphics = ...
barcode.drawBarcode(graphics)
Dim barcodeInBitmap As Bitmap = barcode.drawBarcode()
Dim response As HttpResponse = ...
barcode.drawBarcode(response)
Dim stream As Stream = ...
barcode.drawBarcode(stream)
BarcodeLib
creates and configures a Linear
barcode object with various properties like type, dimensions, and image format. The barcode can be exported in multiple formats besides image files, such as streams and HTTP responses.
IronBarcode and BarcodeLib allow us to recognize barcodes from different image formats and types. Here’s how to do it.
IronBarcode reads barcodes from formats like strings, streams, or images. Here’s how to use it with an image file:
// Read a barcode from an image using IronBarcode
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");
if (QRResult != null)
{
// Output barcode value and type
Console.WriteLine(QRResult.Value);
Console.WriteLine(QRResult.BarcodeType);
}
// Read a barcode from an image using IronBarcode
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");
if (QRResult != null)
{
// Output barcode value and type
Console.WriteLine(QRResult.Value);
Console.WriteLine(QRResult.BarcodeType);
}
' Read a barcode from an image using IronBarcode
Dim QRResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg")
If QRResult IsNot Nothing Then
' Output barcode value and type
Console.WriteLine(QRResult.Value)
Console.WriteLine(QRResult.BarcodeType)
End If
QuicklyReadOneBarcode
is a method to extract barcode data, returning a BarcodeResult
object that provides value and type among other properties (Text, Binary value).
Barcode recognition in BarcodeLib can use files, streams, or bitmaps:
// Configure settings for optimized recognition
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);
// Read barcode from a file using BarcodeLib
string[] results = BarcodeReader.read("c:/code39-barcode.gif", BarcodeReader.CODE39, setting);
// Configure settings for optimized recognition
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);
// Read barcode from a file using BarcodeLib
string[] results = BarcodeReader.read("c:/code39-barcode.gif", BarcodeReader.CODE39, setting);
' Configure settings for optimized recognition
Dim setting As New OptimizeSetting()
setting.setMaxOneBarcodePerPage(True)
Dim top20 As New ScanArea(New PointF(0.0F, 0.0F), New PointF(100.0F, 20.0F))
Dim bottom20 As New ScanArea(New PointF(0.0F, 80.0F), New PointF(100.0F, 100.0F))
Dim areas As New List(Of ScanArea)()
areas.Add(top20)
areas.Add(bottom20)
setting.setAreas(areas)
' Read barcode from a file using BarcodeLib
Dim results() As String = BarcodeReader.read("c:/code39-barcode.gif", BarcodeReader.CODE39, setting)
BarcodeReader
reads barcodes using file paths, converting images to a readable format. It supports multiple types and output options within BarcodeReader.read
, allowing handling of multiple barcode formats simultaneously.
All licenses are perpetual and apply to development, staging, and production.
The Lite License
This license allows a single software developer in an organization to utilize the Iron Software in a single place. Iron Software can be used in a single web application, intranet application, or desktop software program. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, without OEM redistribution and utilizing the Iron Software as a SaaS if additional coverage is not purchased.
Pricing: Starts from $4999 per year.
Professional License:
This allows a predetermined number of software developers in an organization to utilize Iron Software in single locations, up to a maximum of ten. The Iron Software can be used in as many websites, intranet applications, or desktop software applications as you like. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS without purchasing additional coverage. This license can be integrated with a single project up to a maximum of 10.
Pricing: Starts from $2499 per year.
Unlimited License
This allows an unlimited number of software developers in an organization to utilize Iron Software in an unlimited number of locations. The Iron Software can be used in as many websites, intranet applications, or desktop software applications as you like. Licenses are non-transferable, and they cannot be shared outside of an organization or an agency/client relationship. This license type, like all other license types, expressly excludes all rights not expressly granted under the Agreement, including OEM redistribution and utilizing the Iron Software as a SaaS if additional coverage is not purchased.
Pricing: Starts from $4999 per year.
Royalty-Free Redistribution: This allows you to distribute the Iron Software as part of a number of differently packaged commercial products (without having to pay royalties) based on the number of projects covered by the base license. It allows for the deployment of Iron Software within SaaS software services, based on the number of projects covered by the base license.
Pricing: Starts from $3999 per year.
Single Developer License: The Single Developer License allows one developer royalty-free distribution of unlimited user licenses and installation software on unlimited servers, which can be placed in more than one location.
Pricing: Starts from $999 per year.
5-Developer License: This allows five developers royalty-free distribution of unlimited user licenses and installation software on unlimited servers, which can be placed in more than one location.
Pricing: Starts from $1999 per year.
Unlimited Developers License: This allows unlimited developers royalty-free distribution, unlimited user licenses, and installation software on unlimited servers, which can be placed in more than one location.
Pricing: Starts from $2999 per year.
IronBarcode is one of the most powerful libraries for helping generate and recognize barcodes. It is also one of the fastest libraries in terms of barcode generation and recognition. This library is supported by various operating systems. It supports a wide variety of barcode formats and is easy to create. We can change the image format to JPEG and others, and change the color, line height, width, and barcode text.
BarcodeLib.Barcode is also a powerful library that can help us generate and recognize barcodes with different image formats. We can use various image formats to read and create barcodes. BarcodeLib also provides options to change a barcode's appearance, such as height, width, barcode text, etc.
IronBarcode packages provide better licensing and support than BarcodeLib. BarcodeLib is also more expensive, starting at $999 per year, while IronBarcode is clearly cheaper with its starting price of $499. Not only is IronBarcode more cost-effective, but it also provides more features than BarcodeLib. Further, IronBarcode has the advantage of being faster than BarcodeLib. IronBarcode also has various properties which allow us to not only read barcodes from different image formats but also to read barcodes from PDF documents. It also allows us to add images inside the barcode or QR code, a feature that is not available in any other library.
So, what are you waiting for? The free trial is open to all. You can obtain the License here and begin straightaway.
Barcodes are used in inventory management, quality control, and supply chain management to simplify data collection and reduce errors.
Barcodes use the Uniform Code Council (UPC) and International Standards Organization (ISO) coding systems.
BarcodeLib for .NET includes easy-to-use drag-and-drop barcode generation, fully managed C# code, compatibility with ASP.NET applications, support for all barcode standards, and a royalty-free developer license.
IronBarcode enhances reading accuracy by automatically pre-processing barcode images to correct rotation, noise, distortion, and skewing.
IronBarcode offers several licensing models: Lite License for a single developer, Professional License for up to 10 developers, Unlimited License for unlimited developers, and Royalty-Free Redistribution.
IronBarcode can be installed via Visual Studio, Visual Studio Command-Line, or by downloading directly from the NuGet or IronBarcode website.
BarcodeLib offers licenses starting at $999 per year for a single developer, $1999 for 5 developers, and $2999 for unlimited developers.
Yes, IronBarcode can read barcodes from various image formats as well as from PDF documents.
IronBarcode supports saving barcodes in various formats including PDF, JPG, TIFF, GIF, BMP, PNG, and HTML.
IronBarcode is more cost-effective, offers more features, and is faster than BarcodeLib. It supports various barcode formats and allows adding images inside barcodes or QR codes.