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 machine-readable visual representation of data. Barcodes were first used to express data by changing the lengths and spacings of parallel lines. These linear or one-dimensional (1D) barcodes may be scanned using special optical scanners known as barcode readers, of which there are various types. Later, two-dimensional (2D) variations using rectangles, dots, hexagons, and other patterns were developed and dubbed matrix codes, despite the fact that they do not use bars. Purpose-built 2D optical scanners, which come in a variety of configurations, can read 2D barcodes. A digital camera attached to a microcomputer can take a photographic image of a barcode while running software that scans 2D barcodes — it deconstructs and then decodes the barcode by analyzing the image. Using specialized application software, a mobile device with an inbuilt camera, such as a smartphone, can act as the latter sort of 2D barcode scanner.
In this article, we are going to compare two popular barcode libraries:
Both libraries can be used for the generation and recognition of barcodes. There is support for all .NET frameworks, and barcode images can be easily saved.
Aspose.BarCode for .NET is a sophisticated tool that allows you to create and recognize 1D and 2D barcodes from a variety of picture sources at any angle. Barcode creation and scanning capability may be simply added to .NET applications by developers. It also allows for the exporting of created barcodes to multiple high-quality picture formats and APIs for creating new barcodes and recognizing old barcodes from a variety of angles. There is support for over 60 different 1D, 2D, and postal barcode symbologies.
Aspose.BarCode for .NET allows you to change the background color, bar color, rotation angle, x-dimension, image quality, resolution, captions, size, and more for the created barcodes. The API also supports a variety of identification and imaging features, as well as a variety of symbologies.
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. Type, text, binary data, page, and picture files are all included in the barcode result data. The IronBarcode's API features are as follows:
Open Visual Studio, go to the file menu, and select "new project", then select console application/Windows Forms/WPF Application. Barcodes can also be used on all types of applications. You can also 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 dot net framework. The project will now generate 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:
Visual Studio 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 a 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 command in the console tab:
Install-Package BarCode
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.
Click the link here to download the latest package directly from the website. Once downloaded, follow the steps below to add the package to the project.
The Aspose.BarCode library can be downloaded and installed in four ways.
These are:
This method is similar to that described above for IronBarcode. The only thing we need to change is the search criteria, as shown in the image below.
Select the first option which will download the Aspose.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 Aspose.BarCode
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.
Just click here and it will redirect to the NuGet website where you can download the package.
Click the link here and it will redirect to the list of package versions where we can choose the required version to download. Once downloaded, follow the steps below to add the package to the project.
Barcode generation can be done easily with IronBarcode and Aspose.Barcode. Let us take a look at this using an example.
IronBarcode can be used to create a barcode label that can be saved in a variety of image formats. We can also pass the type of barcode that we need to generate. Below is the following snippet for barcode generation:
using IronBarCode;
// Create a barcode using IronBarcode
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);
// Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");
// Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg");
using IronBarCode;
// Create a barcode using IronBarcode
var MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128);
// Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456");
// Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg");
Imports IronBarCode
' Create a barcode using IronBarcode
Private MyBarCode = BarcodeWriter.CreateBarcode("123456", BarcodeEncoding.Code128)
' Add annotation text below the barcode
MyBarCode.AddAnnotationTextBelowBarcode("123456")
' Save the barcode as a JPEG image
MyBarCode.SaveAsImage("MyBarCode.jpeg")
The BarcodeWriter.CreateBarcode
is a method available in the IronBarcode library. We need to pass two parameters to the CreateBarcode
function: the text to encode and the barcode type to generate. After calling this method, it returns a barcode object which can be used to set various properties such as adding annotation text and saving the image in different formats.
// Create a QR code with a logo image
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);
// Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
// Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
// Create a QR code with a logo image
var QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500);
// Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen);
// Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg");
' Create a QR code with a logo image
Dim QRWithLogo = QRCodeWriter.CreateQrCodeWithLogo("Hello World", "logo.png", 500)
' Change the color of the barcode to dark green
QRWithLogo.ChangeBarCodeColor(System.Drawing.Color.DarkGreen)
' Save the QR code with a logo as a JPEG image
QRWithLogo.SaveAsJpeg("Logoqr.jpeg")
The above example demonstrates how to generate a QR code with a logo image using IronBarcode. The CreateQrCodeWithLogo
function allows us to create a QR code with an embedded logo, and we can change the color of the barcode using the ChangeBarCodeColor
method.
Aspose.BarCode can be used for barcode generation, and we can generate different barcode types using the following code snippet:
using Aspose.BarCode.Generation;
// Create a BarcodeGenerator object and specify the barcode type and text
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "123456");
// Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg);
using Aspose.BarCode.Generation;
// Create a BarcodeGenerator object and specify the barcode type and text
BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.Code128, "123456");
// Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg);
Imports Aspose.BarCode.Generation
' Create a BarcodeGenerator object and specify the barcode type and text
Private generator As New BarcodeGenerator(EncodeTypes.Code128, "123456")
' Save the generated barcode as a JPEG image
generator.Save("output.jpg", BarCodeImageFormat.Jpeg)
The above code uses BarcodeGenerator
from Aspose.Barcode to create a barcode. We specify the barcode type and text through the constructor. The Save
method allows us to save the generated barcode in the desired image format, such as JPEG.
Aspose.BarCode also supports customizing the bar height and width using the Parameters.Barcode.XDimension.Millimeters
property to specify line height and width.
Result:
The above image is the performance comparison of these libraries. Time is calculated in milliseconds.
IronBarcode and Aspose.Barcodes allow us to recognize barcodes from different image formats and the types to which they belong. Let's take a look in detail.
IronBarcode helps to read barcodes from different image formats and can be defined in three ways: as a string, as a stream, or as an image such as JPEG, TIFF, Bitmap, etc. The following example is for reading a barcode from an image using the string method.
using IronBarCode;
// Read a barcode from an image file
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");
if (QRResult != null)
{
// Output the barcode value and type
Console.WriteLine(QRResult.Value);
Console.WriteLine(QRResult.BarcodeType);
}
using IronBarCode;
// Read a barcode from an image file
BarcodeResult QRResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg");
if (QRResult != null)
{
// Output the barcode value and type
Console.WriteLine(QRResult.Value);
Console.WriteLine(QRResult.BarcodeType);
}
Imports IronBarCode
' Read a barcode from an image file
Private QRResult As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("MyBarCode.jpg")
If QRResult IsNot Nothing Then
' Output the barcode value and type
Console.WriteLine(QRResult.Value)
Console.WriteLine(QRResult.BarcodeType)
End If
The above code snippet uses BarcodeReader
from IronBarcode to read a barcode from an image file. The QuicklyReadOneBarcode
method reads the barcode from the specified image and converts it into a BarcodeResult
object, which contains properties such as Value
(the encoded text) and BarcodeType
(the type of the recognized barcode).
In Aspose.BarCode for .NET, the source for barcode recognition can be defined in three ways: as an image file, a stream, or a bitmap. The implementation details for reading a barcode from a file in JPEG format are provided below.
using Aspose.BarCode.BarCodeRecognition;
// Read a barcode using Aspose.BarCode
using (BarCodeReader reader = new BarCodeReader(@"MyBarCode.jpg"))
{
// Iterate through recognized barcodes
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Output the barcode type and text
Console.WriteLine("Type: " + result.CodeType);
Console.WriteLine("CodeText: " + result.CodeText);
}
}
using Aspose.BarCode.BarCodeRecognition;
// Read a barcode using Aspose.BarCode
using (BarCodeReader reader = new BarCodeReader(@"MyBarCode.jpg"))
{
// Iterate through recognized barcodes
foreach (BarCodeResult result in reader.ReadBarCodes())
{
// Output the barcode type and text
Console.WriteLine("Type: " + result.CodeType);
Console.WriteLine("CodeText: " + result.CodeText);
}
}
Imports Aspose.BarCode.BarCodeRecognition
' Read a barcode using Aspose.BarCode
Using reader As New BarCodeReader("MyBarCode.jpg")
' Iterate through recognized barcodes
For Each result As BarCodeResult In reader.ReadBarCodes()
' Output the barcode type and text
Console.WriteLine("Type: " & result.CodeType)
Console.WriteLine("CodeText: " & result.CodeText)
Next result
End Using
The above example shows how to read barcodes using Aspose.BarCode. The BarCodeReader
class is used to read the barcode image using the path as a parameter. Then the ReadBarCodes
method fetches all recognized barcodes from the image, and the foreach
loop is used to access each barcode result, providing the barcode type and text encoded within.
IronBarcode is one of the most powerful libraries to help us generate and recognize barcodes. It is also one of the fastest libraries for generating and recognizing barcodes. The library is supported by various operating systems. It supports a wide variety of barcode formats and is easy to create. Users can change color, line height, width, barcode text, etc. The licensing details can be found here.
Aspose.BarCode is also a powerful library for generating and reading barcodes with different image formats. We can use various image formats to read and create. Aspose also provides options for customizing the barcode's appearance, such as height, width, barcode text, etc. Licensing details can be found here.
IronBarcode does enjoy several advantages over Aspose.Barcode. When comparing the processing times for the recognition and generation of barcodes, IronBarcode is faster. IronBarcode also has various properties which allow not only for the reading of barcodes from different image formats but also for reading barcodes from PDF documents. Users can add images inside barcodes and QR codes, a feature not available in many libraries.
A barcode is a machine-readable visual representation of data. It can be either one-dimensional (1D) or two-dimensional (2D), used for encoding information in a format that can be read by specialized scanners or digital cameras.
Aspose.Barcode and IronBarcode are .NET libraries used to create and recognize barcodes. They support various barcode symbologies and can be integrated into .NET applications to handle barcode generation and recognition.
Aspose.Barcode supports over 60 different 1D, 2D, and postal barcode symbologies, including Code128, QR Codes, and more.
IronBarcode can be installed in a .NET project via Visual Studio using NuGet Package Manager, Visual Studio Command-Line, direct download from the NuGet website, or direct download from the IronBarcode website.
Yes, IronBarcode can read barcodes from different image formats, as well as from PDF documents, providing flexibility in barcode recognition.
IronBarcode is generally faster in barcode recognition and generation. It also supports reading barcodes from PDF documents and allows embedding images inside barcodes and QR codes, features not available in many other libraries.
Aspose.Barcode allows customization of barcode appearance by adjusting properties like background color, bar color, rotation angle, x-dimension, image quality, resolution, and more.
IronBarcode can save barcodes in a variety of image formats including JPEG, TIFF, PNG, BMP, GIF, and more. It also supports saving as PDF and HTML.
To create a barcode using IronBarcode, you can use the `BarcodeWriter.CreateBarcode` method, specifying the text to encode and the barcode type. The generated barcode can then be saved in various image formats.
IronBarcode supports both 32 and 64-bit .NET and .NET Core languages, and can be used in web, cloud, desktop, and console applications on mobile and desktop devices.