Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
In this tutorial, we will compare two widely used C# libraries - IronBarcode and QrCoder - for working with QR codes and barcodes.
Let's begin with a brief introduction to both libraries:
IronBarcode is a library created and maintained by Iron Software that enables C# software engineers to read and write barcodes and QR codes in .NET applications and websites. It is available on NuGet for all .NET Frameworks and .NET Core Frameworks. IronBarcode requires only one line of code to read or write barcodes.
QRCoder is a simple C# library that allows you to create QR codes. It has no dependencies on other libraries and is available on NuGet in .NET Framework and .NET Core PCL versions.
Both libraries should have the following main features:
We will implement all of these features from both libraries and compare their performance.
First, let's install both libraries in our Visual Studio project. Since both libraries have their own NuGet packages, we will install them via the NuGet Package Manager Console.
To install IronBarcode, type the following command in the Package Manager Console:
Install-Package BarCode
This will install the IronBarcode library in our project.
Type the following command in Package Manager Console
Install-Package QRCoder
This will install the QrCoder library in our project.
Now, we will generate our first QR code using both libraries.
The following code will generate a QR code.
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var qrCode = QRCodeWriter.CreateQrCode("Iron Barcode Vs QrCoder");
qrCode.SaveAsPng(@"D:\Barcode Images\QrCodeByIronBarcode");
stopwatch.Stop();
Console.WriteLine($"Execution Time: {stopwatch.ElapsedMilliseconds} ms");
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
var qrCode = QRCodeWriter.CreateQrCode("Iron Barcode Vs QrCoder");
qrCode.SaveAsPng(@"D:\Barcode Images\QrCodeByIronBarcode");
stopwatch.Stop();
Console.WriteLine($"Execution Time: {stopwatch.ElapsedMilliseconds} ms");
Dim stopwatch As New Stopwatch()
stopwatch.Start()
Dim qrCode = QRCodeWriter.CreateQrCode("Iron Barcode Vs QrCoder")
qrCode.SaveAsPng("D:\Barcode Images\QrCodeByIronBarcode")
stopwatch.Stop()
Console.WriteLine($"Execution Time: {stopwatch.ElapsedMilliseconds} ms")
The Stopwatch
instance is created to measure the execution time of the program to analyze the efficiency of the library.
IronBarcode takes 3503 ms to generate and save a QR Code.
The following sample code will generate a QR code using QrCoder.
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode("Iron Barcode Vs QrCoder", QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
qrCodeImage.Save(@"D:\Barcode Images\QrCodeByQrCoder.png");
QRCodeGenerator qrGenerator = new QRCodeGenerator();
QRCodeData qrCodeData = qrGenerator.CreateQrCode("Iron Barcode Vs QrCoder", QRCodeGenerator.ECCLevel.Q);
QRCode qrCode = new QRCode(qrCodeData);
Bitmap qrCodeImage = qrCode.GetGraphic(20);
qrCodeImage.Save(@"D:\Barcode Images\QrCodeByQrCoder.png");
Dim qrGenerator As New QRCodeGenerator()
Dim qrCodeData As QRCodeData = qrGenerator.CreateQrCode("Iron Barcode Vs QrCoder", QRCodeGenerator.ECCLevel.Q)
Dim qrCode As New QRCode(qrCodeData)
Dim qrCodeImage As Bitmap = qrCode.GetGraphic(20)
qrCodeImage.Save("D:\Barcode Images\QrCodeByQrCoder.png")
QrCoder does not provide a built-in function to save the QR code as an image. However, we can save it by parsing the QrCoder into a Bitmap object. We can then save the QR code using the save function provided by Bitmap.
QrCoder takes 592 ms to generate and save a QR Code.
The execution time taken by IronBarcode is 3503 ms, while QrCoder only takes 592 ms. This makes QrCoder than IronBarcode in terms of performance.
Generating QR codes is much simpler in IronBarcode, as we only need to write two lines of code. With the QrCoder library, it takes five lines of code.
IronBarcode also provides a built-in function to save generated QR codes in a file, while QrCoder does not. We have to create a bitmap object to save the QR code in a file. This requires us to create four objects to generate QR codes using QrCoder. We only need to create one object in IronBarcode to do the same thing.
Next, we will generate barcodes using both libraries.
The following code will generate a barcode using IronBarcode:
var barcode = BarcodeWriter.CreateBarcode("Iron Barcode Vs QrCoder", BarcodeEncoding.Code128);
barcode.SaveAsPng(@"D:\Barcode Images\BarcodeByIronBarcode.png");
var barcode = BarcodeWriter.CreateBarcode("Iron Barcode Vs QrCoder", BarcodeEncoding.Code128);
barcode.SaveAsPng(@"D:\Barcode Images\BarcodeByIronBarcode.png");
Dim barcode = BarcodeWriter.CreateBarcode("Iron Barcode Vs QrCoder", BarcodeEncoding.Code128)
barcode.SaveAsPng("D:\Barcode Images\BarcodeByIronBarcode.png")
The execution time taken to generate a barcode using IronBarcode is below:
It takes 3756 ms or 3.76 sec to generate a barcode.
It's worth noting that the QrCoder library does not provide the functionality to create barcodes. Therefore, if you need to create barcodes, IronBarcode is the better option.
With regards to QR code scanning, let's see which library is the best option.
The following code will read a QR code using IronBarcode.
BarcodeResults results = BarcodeReader.Read(@"D:\Barcode Images\QrcodeByIronBarcode.png");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine("Extracted text from QR Code is: "+result.Text);
}
}
BarcodeResults results = BarcodeReader.Read(@"D:\Barcode Images\QrcodeByIronBarcode.png");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine("Extracted text from QR Code is: "+result.Text);
}
}
Dim results As BarcodeResults = BarcodeReader.Read("D:\Barcode Images\QrcodeByIronBarcode.png")
If results IsNot Nothing Then
For Each result As BarcodeResult In results
Console.WriteLine("Extracted text from QR Code is: " & result.Text)
Next result
End If
IronBarcode returns an Enumerable
as a result of reading QR codes. We need to loop through the Enumerable
to retrieve each result. This feature is beneficial for reading QR codes from a document or from an image that has more than one QR code.
It takes 3136 ms or 3.1 seconds using IronBarcode.
The QrCoder Library does not provide the functionality for reading or scanning a QR Code.
The following code will scan the barcode using IronBarcode.
BarcodeResults results = BarcodeReader.Read(@"D:\Barcode Images\BarcodeByIronBarcode.png");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine("Text Extracted from Barcode is: " + result.Text);
}
}
BarcodeResults results = BarcodeReader.Read(@"D:\Barcode Images\BarcodeByIronBarcode.png");
if (results != null)
{
foreach (BarcodeResult result in results)
{
Console.WriteLine("Text Extracted from Barcode is: " + result.Text);
}
}
Dim results As BarcodeResults = BarcodeReader.Read("D:\Barcode Images\BarcodeByIronBarcode.png")
If results IsNot Nothing Then
For Each result As BarcodeResult In results
Console.WriteLine("Text Extracted from Barcode is: " & result.Text)
Next result
End If
IronBarcode returns Enumerable
as a result of reading barcodes. We need to loop through it to get each result. It is beneficial for reading Barcode from a document or image which have more than one barcode.
The output generated by the above code is as:
QrCoder Library does not provide the functionality of reading or scanning QR Code.
Now, Let's discuss the license options of both libraries.
IronBarcode is free for development. However, It requires a license for deployment outside of the visual studio development environment. License price range from $749 to $2999 (USD). You can get a discount if you purchase the complete Iron Suite.
QrCoder is open source, hence does not require any licensing. You are free to use it in any type of environment. You can also contribute to its source code if you like open-source development.
If we only need the functionality of generating QR codes, QRCoder is the best option to use as it is free to use and doesn't require any payment or subscription fees.
IronBarcode is a great option when we require functionalities beyond generating QR codes, such as:
The table below compares both IronBarcode and QrCoder.
IronBarcode for .NET allows developers to read and write barcodes and QR codes in their .NET applications using just one line of code. The library supports most barcode and QR code standards, including 39/93/128, UPC A/E, EAN 8/13, and QR, among others. The library automatically pre-processes barcode images and offers correction for rotation, noise, distortion, and skewing to improve speed and accuracy. IronBarcode is compatible with 32- and 64-bit systems, all .NET languages, and a variety of platforms, including desktop, console, cloud, and mobile and web applications. It also allows developers to write barcodes and QR codes for PDF, JPG, TIFF, GIF, BMP, PNG, and HTML documents, and modify text color, size, rotation, and quality. The library is secure and does not use web services or send data across the internet. IronBarcode is available for a free trial and offers three licensing options, including a Lite version for individual use, a Professional package for teams of up to 10 developers, and an Unlimited package for companies.
QRCoder is a C# .NET library that generates QR codes based on ISO/IEC 18004 without dependencies on other libraries. It offers several QR code rendering classes, including QRCode, ArtQRCode, AsciiQRCode, and others. However, not all renderers are available on all target frameworks, and the .NET Standard/.NET >=5.0 versions have some constraints. QRCoder is free and does not require licensing.
IronBarcode is more versatile than QRCoder since it offers support for all .NET Framework versions, has a wider range of features, and provides SaaS and OEM Redistribution coverage. IronBarcode also provides comprehensive documentation and 24/7 support, while QRCoder does not. IronBarcode has a licensing fee, but it is reasonable considering the features and support it offers.
IronBarcode is a library developed by Iron Software, which also offers other useful libraries, including IronPDF, IronXL, IronOCR, and IronWebScraper. Purchase the complete Iron Suite to get all five products at a remarkable discount.
In summary, IronBarcode is best suited for those who need to work with both barcodes and QR codes and want to create a barcode generator, QR code generator, barcode reader, and QR code reader. On the other hand, QRCoder is suitable for those who only need to create a QR code generator.
9 .NET API products for your office documents