Test in a live environment
Test in production without watermarks.
Works wherever you need it to.
Creating QR codes in C# applications is a common requirement for developers, especially for applications involving product identification, ticketing, or sharing URLs and other data easily. There are several libraries available for generating QR codes in C#. Two notable options are QRCoder and IronQR. Here, we'll explore both, comparing their capabilities, ease of use, performance, and other factors relevant for developers working with .NET 6. In this article, we'll delve into a detailed comparison of these libraries, examining their features, ease of use, license, and more, along with code samples to illustrate their usage.
QRCoder is an open-source library written in C# and QR Code implementation that allows you to generate QR Codes as defined by ISO/IEC 18004 in any .NET application. It’s a lightweight and easy-to-use library with no dependencies on other libraries or network stacks.
Here are the key features and benefits of QRCoder:
C# QRCoder offers a straightforward and intuitive API, making it easy for developers to generate QR codes/ QR code text with minimal effort. Its simplicity allows developers of all skill levels to quickly integrate QR code generation into their projects.
One of the standout features of QRCoder is its ability to customize QR codes according to specific requirements. Developers can adjust parameters such as error correction level, size, color, and even embed logos or images within the QR code.
QRCoder supports various encoding formats, enabling developers to encode different types of data into QR codes. Whether it's plain text, URLs, contact information, or Wi-Fi credentials, QRCoder can handle a wide range of data formats.
The QR codes generated by C# QRCoder are of high quality, ensuring readability and reliability across different devices and scanning conditions. This reliability is crucial for applications where QR codes serve as a bridge between physical and digital interactions.
C# QRCoder is an open-source project, allowing developers to contribute to its development and ensuring continuous improvements and updates. This active community engagement fosters innovation and ensures that the library remains relevant in the ever-evolving landscape of technology.
IronQR is a powerful C# QR Code library developed and maintained by Iron Software. It allows C# software engineers to detect, read, and create QR Codes in .NET applications and websites. Here are some key features of IronQR:
IronQR enables highly customizable QR code generation. You can create QR codes with various options, such as resizing, margins, borders, and recoloring.
using IronQr;
using IronSoftware.Drawing;
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
using IronQr;
using IronSoftware.Drawing;
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
Imports IronQr
Imports IronSoftware.Drawing
' Prepare a QR Code object
Private theQrGen As QrCode = QrWriter.Write("Awesome IronQR")
' Save QR Code to memory
Private myQrImage As AnyBitmap = theQrGen.Save()
' Save QR Code image to disk
myQrImage.SaveAs("awesome.png")
IronQR uses an advanced Machine Learning Model for QR code detection. This model ensures accurate and fast QR code reading. IronQR supports reading QR codes from various image formats, including JPG, PNG, SVG, bmp, and multipage images like gif and tiff.
using IronQr;
using IronSoftware.Drawing;
using System.Collections.Generic;
// Read QR code
var inputBmp = AnyBitmap.FromFile("awesome.png");
// Load the image into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create the QR Reader object
QrReader reader = new QrReader();
// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
using IronQr;
using IronSoftware.Drawing;
using System.Collections.Generic;
// Read QR code
var inputBmp = AnyBitmap.FromFile("awesome.png");
// Load the image into QrImageInput
QrImageInput imageInput = new QrImageInput(inputBmp);
// Create the QR Reader object
QrReader reader = new QrReader();
// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
Imports IronQr
Imports IronSoftware.Drawing
Imports System.Collections.Generic
' Read QR code
Private inputBmp = AnyBitmap.FromFile("awesome.png")
' Load the image into QrImageInput
Private imageInput As New QrImageInput(inputBmp)
' Create the QR Reader object
Private reader As New QrReader()
' Read the Input an get all embedded QR Codes
Private results As IEnumerable(Of QrResult) = reader.Read(imageInput)
You can encode various types of data in QR codes, including text, URLs, bytes, and numbers.
IronQR provides detailed error messages and custom error correction options.
Trusted by Millions, IronQR is trusted by engineers worldwide for its reliability and ease of use. To get started with IronQR, you can install it via NuGet.
To get started with the code, let us create a Visual Studio Project. Open Microsoft Visual Studio 2022 and select "Create a new project" option.
Select the Console application template from the template list
Then provide the project name and the solution names. Select the path to store the project files
Select the required .NET version. I will go with the latest .NET 8 framework at the time of writing this article.
Once you click the create button the project is created and ready for development.
The QRCoder NuGet package can be installed using Visual Studio NuGet package manager as shown below.
Or install it from NuGet package manager console using the following command
dotnet add package QRCoder --version 1.4.3
dotnet add package QRCoder --version 1.4.3
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'dotnet add package QRCoder --version 1.4.3
The QRCoder NuGet package is available on the NuGet website here
The IronQR can also be installed similarly using the Visual Studio NuGet package manager, shown below.
Also from the NuGet package manager console, use the following command
dotnet add package IronQR --version 2024.4.1
dotnet add package IronQR --version 2024.4.1
'INSTANT VB TODO TASK: The following line uses invalid syntax:
'dotnet add package IronQR --version 2024.4.1
Creating QR codes in the two libraries requires simple code, let's check them out
The following code shows how to generate our first QR code using QRCoder
using QRCoder;
using System.Drawing;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
using (var qrCode = new QRCoder.BitmapByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(20);
var file = Image.FromStream(new MemoryStream(qrCodeImage));
file.Save("QrCoderDemo1.png");
}
}
}
}
using QRCoder;
using System.Drawing;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
using (var qrCode = new QRCoder.BitmapByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(20);
var file = Image.FromStream(new MemoryStream(qrCodeImage));
file.Save("QrCoderDemo1.png");
}
}
}
}
Imports QRCoder
Imports System.Drawing
Namespace QRCoderVsIronQR
Public Class Program
Public Shared Sub Main()
Using qrGenerator As New QRCodeGenerator()
Using qrCodeData As QRCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q)
Using qrCode = New QRCoder.BitmapByteQRCode(qrCodeData)
Dim qrCodeImage = qrCode.GetGraphic(20)
Dim file = Image.FromStream(New MemoryStream(qrCodeImage))
file.Save("QrCoderDemo1.png")
End Using
End Using
End Using
End Sub
End Class
End Namespace
The following code shows how to generate QR code using IronQR:
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
}
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
{
public class Program
{
public static void Main()
{
// Prepare a QR Code object
QrCode theQrGen = QrWriter.Write("Awesome IronQR");
// Save QR Code to memory
AnyBitmap myQrImage = theQrGen.Save();
// Save QR Code image to disk
myQrImage.SaveAs("awesome.png");
}
}
}
Imports IronQr
Imports IronSoftware.Drawing
Namespace QrCodeWithIronQR
Public Class Program
Public Shared Sub Main()
' Prepare a QR Code object
Dim theQrGen As QrCode = QrWriter.Write("Awesome IronQR")
' Save QR Code to memory
Dim myQrImage As AnyBitmap = theQrGen.Save()
' Save QR Code image to disk
myQrImage.SaveAs("awesome.png")
End Sub
End Class
End Namespace
As you can already see the difference in the amount of code. IronQR code generation requires less code.
The output has an IronQR watermark since I am using a trial version of the library. With a licensed version, this will be removed.
Both libraries support customization options. Let's look at some options available
We can set the QR code colors in QRCoder like below:
using QRCoder;
using System.Drawing;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
using (var qrCode = new QRCoder.BitmapByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(20, [255,0,0], [0,255, 0]); // can also use html hex color notation
var file = Image.FromStream(new MemoryStream(qrCodeImage));
file.Save("QrCoderDemo1.png");
}
}
}
}
using QRCoder;
using System.Drawing;
namespace QRCoderVsIronQR
{
public class Program
{
public static void Main()
{
using (QRCodeGenerator qrGenerator = new QRCodeGenerator())
using (QRCodeData qrCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q))
using (var qrCode = new QRCoder.BitmapByteQRCode(qrCodeData))
{
var qrCodeImage = qrCode.GetGraphic(20, [255,0,0], [0,255, 0]); // can also use html hex color notation
var file = Image.FromStream(new MemoryStream(qrCodeImage));
file.Save("QrCoderDemo1.png");
}
}
}
}
Imports QRCoder
Imports System.Drawing
Namespace QRCoderVsIronQR
Public Class Program
Public Shared Sub Main()
Using qrGenerator As New QRCodeGenerator()
Using qrCodeData As QRCodeData = qrGenerator.CreateQrCode("QRCoder Demo 1", QRCodeGenerator.ECCLevel.Q)
Using qrCode = New QRCoder.BitmapByteQRCode(qrCodeData)
Dim qrCodeImage = qrCode.GetGraphic(20, (255,0,0), (0,255, 0)) ' can also use html hex color notation
Dim file = Image.FromStream(New MemoryStream(qrCodeImage))
file.Save("QrCoderDemo1.png")
End Using
End Using
End Using
End Sub
End Class
End Namespace
We can set colors for IronQR QR code generation like following code:
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
public class Program
{
public static void Main()
{
// Set options
QrOptions options = new QrOptions(QrErrorCorrectionLevel.Medium, 20);
// Create QR
QrCode myQr = QrWriter.Write("IronQR Generation Demo 1", options);
// Style options
AnyBitmap logoBmp = new AnyBitmap("logo.png");
QrStyleOptions style = new QrStyleOptions
{
BackgroundColor = Color.Aqua,
Dimensions = 300, // px
Margins = 10, // px
Color = Color.Red,
Logo = new QrLogo
{
Bitmap = logoBmp,
Width = 100,
Height = 100,
CornerRadius = 2
}
};
// Save QR Code
AnyBitmap qrImage = myQr.Save(style);
// Save QR Code to local disk
qrImage.SaveAs("advancedQr.png");
}
}
}
using IronQr;
using IronSoftware.Drawing;
namespace QrCodeWithIronQR
public class Program
{
public static void Main()
{
// Set options
QrOptions options = new QrOptions(QrErrorCorrectionLevel.Medium, 20);
// Create QR
QrCode myQr = QrWriter.Write("IronQR Generation Demo 1", options);
// Style options
AnyBitmap logoBmp = new AnyBitmap("logo.png");
QrStyleOptions style = new QrStyleOptions
{
BackgroundColor = Color.Aqua,
Dimensions = 300, // px
Margins = 10, // px
Color = Color.Red,
Logo = new QrLogo
{
Bitmap = logoBmp,
Width = 100,
Height = 100,
CornerRadius = 2
}
};
// Save QR Code
AnyBitmap qrImage = myQr.Save(style);
// Save QR Code to local disk
qrImage.SaveAs("advancedQr.png");
}
}
}
Imports IronQr
Imports IronSoftware.Drawing
namespace QrCodeWithIronQR Public Class Program
Public Shared Sub Main()
' Set options
Dim options As New QrOptions(QrErrorCorrectionLevel.Medium, 20)
' Create QR
Dim myQr As QrCode = QrWriter.Write("IronQR Generation Demo 1", options)
' Style options
Dim logoBmp As New AnyBitmap("logo.png")
Dim style As New QrStyleOptions With {
.BackgroundColor = Color.Aqua,
.Dimensions = 300,
.Margins = 10,
.Color = Color.Red,
.Logo = New QrLogo With {
.Bitmap = logoBmp,
.Width = 100,
.Height = 100,
.CornerRadius = 2
}
}
' Save QR Code
Dim qrImage As AnyBitmap = myQr.Save(style)
' Save QR Code to local disk
qrImage.SaveAs("advancedQr.png")
End Sub
End Class
}
With IronQR there are many customization options. In the above program we have tried to customize the background color, QR code color, margins. We can also set dimensions.
QRCoder is a MIT license-based package and is developed with the help of the community. This package is good for small-budget projects. The user needs to wait for the community to resolve issues or can fix and push the code to the Git Repository with pull requests approved.
IronQR to be used in applications. It has backing from Iron Software.
IronQR which can be obtained. The obtained key needs to be placed in the appSettings.json file here:
{
"IronQR.License.LicenseKey":"myKey"
}
{
"IronQR.License.LicenseKey":"myKey"
}
If True Then
"IronQR.License.LicenseKey":"myKey"
End If
Choosing between C# QRCoder and IronQR ultimately depends on the specific requirements of your project. If you need a free and open source QR code generation library with a lot of customization options, then C# QRCoder might be the preferred choice due to its simplicity and extensive customization options.
If you need an enterprise-level library that supports not only QR code generation with customization options but also supports QR code reading, then IronQR would be the ultimate choice. So ultimately, with IronQR library, its many benefits and support functionality from Iron Software, developers can write enterprise applications with ease and peace of mind.
9 .NET API products for your office documents