A Comparison between IronBarcode and Spire Barcode

A barcode is a type of machine-readable code which stores information about various items in the form of lines and spaces arranged in a pattern. Barcodes are made up of a series of parallel bars that are used to encode data. These bars make up what is called a "barcode" or "barcode symbol" which can be read by a barcode scanner (sometimes just called a "scanner"). All barcodes have four parts:

  • Start Character
  • Tolerances: the number of changes allowed for the widths and heights, usually as percentages
  • Data Characters: the characters used to represent the information encoded
  • Stop Character

Barcodes are the most efficient way to identify products in a retail environment. Every product has a barcode that is unique and can be scanned with a scanner for inventory control or for price verification. Nowadays, barcodes are not just used as an efficient way of identifying products in a retail environment, they have become an important aspect of our everyday life because they are used to store information electronically and manage consumer identities.

In this article, we are going to compare two popular barcode libraries:

  • Spire Barcode
  • IronBarcode

Both of these libraries can be used for the generation and recognition of barcodes, provide support for all dot net frameworks, and allow you to save the barcode images.

IronBarcode

We will look at how to generate a barcode in C# .NET with the IronBarcode library by using an example. We will see how easy it is to create a barcode, as well as how to style our barcode and then export it using IronBarocde.

Installation

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.

Install the IronBarcode Library

1 Using IronBarcode

The IronBarcode Library can be downloaded and installed in four ways:

These are:

  • Using Visual Studio
  • Using the Visual Studio Command-Line.
  • Direct download from the NuGet website.
  • Direct download from the IronBarcode website.

1.1 Using Visual Studio

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.

1.2 Using the Visual Studio Command-Line

In Visual Studio tools, 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.

1.3 Direct Download from the NuGet Website

The third way is to download the package directly from the website.

  • Navigate to the Link.
  • Select the download package option from the right-hand side menu.
  • Double-click the downloaded package. It will be installed automatically.
  • Now reload the solution and start using it in the project.

1.4 Direct Download from the IronBarcode 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.

  • Right-click the project from the solution window.
  • Then, select the option reference and browse the location of the downloaded reference.
  • Then, click OK to add the reference.

The first thing we need to do is install the Iron Barcode 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

Add the Back-End Code for Browsing the File

In the following example we can see that a barcode can be written containing numerical or text content using only a couple of lines of code with IronBarcode.

// Generate a Simple BarCode image and save as PNG
//using IronBarCode;
GeneratedBarcode MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128);
MyBarCode.SaveAsPng("MyBarCode.png");
// This line opens the image in your default image viewer
System.Diagnostics.Process.Start("MyBarCode.png");
// Generate a Simple BarCode image and save as PNG
//using IronBarCode;
GeneratedBarcode MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128);
MyBarCode.SaveAsPng("MyBarCode.png");
// This line opens the image in your default image viewer
System.Diagnostics.Process.Start("MyBarCode.png");
' Generate a Simple BarCode image and save as PNG
'using IronBarCode;
Dim MyBarCode As GeneratedBarcode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.Code128)
MyBarCode.SaveAsPng("MyBarCode.png")
' This line opens the image in your default image viewer
System.Diagnostics.Process.Start("MyBarCode.png")
VB   C#

We first create the barcode by specifying its value, and the barcode format we will be using is from the IronBarCode.BarcodeWriterEncoding Enum. We can then choose to save as an image, or as a System.Drawing.Image, or as a Bitmap object. That's all the code it takes! The final line of code simply opens the barcode PNG in the example so that you can see it with your own eyes.

Advanced Barcode using IronBarcode

Although the previous example was effective, in the real world we may wish to do more. In the following example, we may add annotations to the barcode, set the font, display its value below it, add margins, change the barcode color, and then save it, all quite simply in C#. We can also choose to export to HTML or PDF instead of an image, if that is more appropriate for our application.

//using IronBarCode;
//using System.Drawing;
// Styling a QR code and adding annotation text
var MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode);
MyBarCode.AddAnnotationTextAboveBarcode("Product URL:");
MyBarCode.AddBarcodeValueTextBelowBarcode();
MyBarCode.SetMargins(100);
MyBarCode.ChangeBarCodeColor(Color.Purple);
// Save as HTML
MyBarCode.SaveAsHtmlFile("MyBarCode.html"); 
//using IronBarCode;
//using System.Drawing;
// Styling a QR code and adding annotation text
var MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode);
MyBarCode.AddAnnotationTextAboveBarcode("Product URL:");
MyBarCode.AddBarcodeValueTextBelowBarcode();
MyBarCode.SetMargins(100);
MyBarCode.ChangeBarCodeColor(Color.Purple);
// Save as HTML
MyBarCode.SaveAsHtmlFile("MyBarCode.html"); 
'using IronBarCode;
'using System.Drawing;
' Styling a QR code and adding annotation text
Dim MyBarCode = IronBarCode.BarcodeWriter.CreateBarcode("https://ironsoftware.com/csharp/barcode", BarcodeWriterEncoding.QRCode)
MyBarCode.AddAnnotationTextAboveBarcode("Product URL:")
MyBarCode.AddBarcodeValueTextBelowBarcode()
MyBarCode.SetMargins(100)
MyBarCode.ChangeBarCodeColor(Color.Purple)
' Save as HTML
MyBarCode.SaveAsHtmlFile("MyBarCode.html")
VB   C#

The code should be self-explanatory, but if it is not, I encourage you to read the GeneratedBarcode class documentation within the API Reference.

Reading a Barcode

Reading a barcode or QR code in .NET is incredibly easy using the IronBarcode class library with .NET Barcode Reader. In our first example, we can see how to read this barcode with one line of code.

Barcode Image to be Scanned with C#

We can extract its value, its image, its encoding type, its binary data (if any), and we can then output that to the console.

using IronBarCode;
using System;
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");
if (Result !=null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
{
  Console.WriteLine("GetStarted was a success.  Read Value: " + Result.Text);
}
using IronBarCode;
using System;
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png");
if (Result !=null && Result.Text == "https://ironsoftware.com/csharp/barcode/")
{
  Console.WriteLine("GetStarted was a success.  Read Value: " + Result.Text);
}
Imports IronBarCode
Imports System
Private Result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("GetStarted.png")
If Result IsNot Nothing AndAlso Result.Text = "https://ironsoftware.com/csharp/barcode/" Then
  Console.WriteLine("GetStarted was a success.  Read Value: " & Result.Text)
End If
VB   C#

We will add our TryHarder variable to the QuicklyReadOneBarcode method. This makes it try harder, literally taking more time, but scanning deeper for a QR code that might be obscured, corrupted, or at a skewed angle.

BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("TryHarderQR.png", BarcodeEncoding.QRCode | BarcodeEncoding.Code128 , true);
BarcodeResult Result = BarcodeReader.QuicklyReadOneBarcode("TryHarderQR.png", BarcodeEncoding.QRCode | BarcodeEncoding.Code128 , true);
Dim Result As BarcodeResult = BarcodeReader.QuicklyReadOneBarcode("TryHarderQR.png", BarcodeEncoding.QRCode Or BarcodeEncoding.Code128, True)
VB   C#

It can now read this skewed QR Code:

Scanning a QR code rotated through 45 degrees with C#

You will see that we can specify the barcode encoding(s) that we are looking for or specify multiple formats. Doing so greatly improves barcode reading performance and accuracy. The pipe character or 'Bitwise OR' is used to specify multiple formats simultaneously. The same can be achieved, but with a higher degree of specificity, if we move forwards to using the visual method or the BarcodeReader.ReadASingleBarcode method component mode.

Reading Barcodes from Imperfect Images

In real-world use cases, we may wish to read barcodes that are not perfect screenshots. They may be imperfect images, scans, or photographs, and contain digital noise or be skewed. With most conventional open source .net barcode generators and reader libraries, this would be impossible. However, this Barcodes Reader in C# makes it incredibly straightforward. We will look at the TryHarder method of QuicklyReadOneBarcode. This single parameter causes Iron Barcode to try to de-skew and read barcodes from imperfect digital samples.

We will set the specific barcode rotation correction and barcode image correction to correct for the digital noise, as well as the skew, perspective and rotation that we might reasonably expect from a cellphone camera.

Reading a barcode from a phone camera in C#

using IronBarCode;
using System;
using System.Drawing;
var PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels);
string Value = PhotoResult.Value;
System.Drawing.Bitmap Img = PhotoResult.BarcodeImage;
BarcodeEncoding BarcodeType = PhotoResult.BarcodeType;
byte[] Binary = PhotoResult.BinaryValue;
Console.WriteLine(PhotoResult.Value);  
using IronBarCode;
using System;
using System.Drawing;
var PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels);
string Value = PhotoResult.Value;
System.Drawing.Bitmap Img = PhotoResult.BarcodeImage;
BarcodeEncoding BarcodeType = PhotoResult.BarcodeType;
byte[] Binary = PhotoResult.BinaryValue;
Console.WriteLine(PhotoResult.Value);  
Imports IronBarCode
Imports System
Imports System.Drawing
Private PhotoResult = BarcodeReader.ReadASingleBarcode("Photo.png", BarcodeEncoding.Code128, BarcodeReader.BarcodeRotationCorrection.Medium, BarcodeReader.BarcodeImageCorrection.DeepCleanPixels)
Private Value As String = PhotoResult.Value
Private Img As System.Drawing.Bitmap = PhotoResult.BarcodeImage
Private BarcodeType As BarcodeEncoding = PhotoResult.BarcodeType
Private Binary() As Byte = PhotoResult.BinaryValue
Console.WriteLine(PhotoResult.Value)
VB   C#

Fluency

In our final example, we will see that we can create, style, and export a barcode with a single line of code. IronBarcode implements an optional fluent API similar to System. Linq. By chaining method calls to method calls to method calls, we first create a barcode, then set its margins, then export it to Bitmap in a single line. This can be very convenient and make code easier to read.

Spire BarCode

Free Spire.Barcode for .NET is a free and professional barcode API specially designed for .NET developers (C#, VB.NET, ASP.NET) to generate and read 1D & 2D barcodes. Developers and programmers can use Spire.BarCode to add enterprise-level barcode formats to their .net applications, asp.net Winforms, and Web Service quickly, net applications asp.net Winforms, and easily. Free Spire.Barcode for .NET provides a very easy way to integrate barcode processing. spire create, read 1D & 2D barcode, Spire.BarCode supports variable common image formats, such as Bitmap, JPG, PNG, EMF, TIFF, GIF, and WMF. It also provides support for QR codes.

Installation

The first thing we need to do is install the Spire library, adding barcode functionality to the .NET framework. We can do this by using the NuGet package. As we did in the case of IronBarcode, the process is the same — follow the same steps and just type "Spire barcode" and add the packages to a project.

Writing Barcode Developers

The library provides methods that are used to create barcode images. It is an overloaded method. In this part I list the definitions of the methods. These methods will be used in the code to test the performance of the library

using Spire.Barcode;
using System.Drawing;
namespace QRCode
{
    class Program
    {
        static void Main(string[] args)
        {
            BarcodeSettings settings = new BarcodeSettings();
            settings.Type = BarCodeType.QRCode;
            settings.Data = "Hello world";
            settings.Data2D = "Hello 123456789";
            settings.QRCodeDataMode = QRCodeDataMode.AlphaNumber;
            settings.X = 1.0f;
            settings.QRCodeECL = QRCodeECL.H;
            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image image = generator.GenerateImage();
            image.Save("QRCode.png");
        }
    }
}
using Spire.Barcode;
using System.Drawing;
namespace QRCode
{
    class Program
    {
        static void Main(string[] args)
        {
            BarcodeSettings settings = new BarcodeSettings();
            settings.Type = BarCodeType.QRCode;
            settings.Data = "Hello world";
            settings.Data2D = "Hello 123456789";
            settings.QRCodeDataMode = QRCodeDataMode.AlphaNumber;
            settings.X = 1.0f;
            settings.QRCodeECL = QRCodeECL.H;
            BarCodeGenerator generator = new BarCodeGenerator(settings);
            Image image = generator.GenerateImage();
            image.Save("QRCode.png");
        }
    }
}
Imports Spire.Barcode
Imports System.Drawing
Namespace QRCode
	Friend Class Program
		Shared Sub Main(ByVal args() As String)
			Dim settings As New BarcodeSettings()
			settings.Type = BarCodeType.QRCode
			settings.Data = "Hello world"
			settings.Data2D = "Hello 123456789"
			settings.QRCodeDataMode = QRCodeDataMode.AlphaNumber
			settings.X = 1.0F
			settings.QRCodeECL = QRCodeECL.H
			Dim generator As New BarCodeGenerator(settings)
			Dim image As Image = generator.GenerateImage()
			image.Save("QRCode.png")
		End Sub
	End Class
End Namespace
VB   C#

The produced QR barcode image looks as follows.

Create a QR Code in C#

//Generate the barcode based on the this.barCodeControl1
BarCodeGenerator generator = new BarCodeGenerator(this.barCodeControl1);
Image barcode = generator.GenerateImage();

//save the barcode as an image
barcode.Save("barcode.png");
//Generate the barcode based on the this.barCodeControl1
BarCodeGenerator generator = new BarCodeGenerator(this.barCodeControl1);
Image barcode = generator.GenerateImage();

//save the barcode as an image
barcode.Save("barcode.png");
'Generate the barcode based on the this.barCodeControl1
Dim generator As New BarCodeGenerator(Me.barCodeControl1)
Dim barcode As Image = generator.GenerateImage()

'save the barcode as an image
barcode.Save("barcode.png")
VB   C#

There are two import classes — BarCodeControl and BarCodeGenerator in this method. BarCodeControl stores information about barcodes. BarCodeGenerator is the class to generate barcode images. Its constructor takes one parameter — a BarCodeControl instance. It has a method called GenerateImage() whose return value is the Image object to generate an image.

Reading Barcode Images

The barcode scanner is the class to scan barcode images. Call its method Scan with the Bitmap object containing the barcode image; it returns a string [] value where the scanning result is stored. The class BarcodeScanner to scan barcode images in its code. It can store and add enterprise-level barcodes in VB.NET and C#.

Here is the code:

private void btnScan_Click(object sender, EventArgs e)
{
//scan the barcode
string[] datas = Spire.Barcode.BarcodeScanner.Scan("barcode.png");

//show the scan result
this.TextB_ScanResult.Text = datas[0];
}
private void btnScan_Click(object sender, EventArgs e)
{
//scan the barcode
string[] datas = Spire.Barcode.BarcodeScanner.Scan("barcode.png");

//show the scan result
this.TextB_ScanResult.Text = datas[0];
}
Private Sub btnScan_Click(ByVal sender As Object, ByVal e As EventArgs)
'scan the barcode
Dim datas() As String = Spire.Barcode.BarcodeScanner.Scan("barcode.png")

'show the scan result
Me.TextB_ScanResult.Text = datas(0)
End Sub
VB   C#

IronBarcode and Spire.Barcode Licensing Models and Pricing

IronBarcode License Model and Price

The 30-day money-back guarantee: when the license is purchased you will get 30 days of money back up it the license does not work or the iron barcode does not allow then you can get your money back within 30days.

Easy integration: the integration of IronPDF with your project and your environment is so easy that we can achieve it just by writing a single line of code when adding from NuGet Package, or if we download it from the web, we can integrate it with our environment that way.

Perpetual licensing: each license is purchased once and does not require renewal.

Free support & product updates: every license comes with a year of free product updates and support from the team behind the product. It is possible to purchase extensions at any moment. Extensions can be viewed.

Immediate licenses: registered license keys are sent out as soon as payment is received.

All licenses are perpetual and apply to development, staging, and production.

The Lite Package:

  • 1 developer
  • 1 location
  • 1 project
  • Perpetual license

This package 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 SaaS if additional coverage is not purchased.

Pricing: Starts from $749 per year.

Professional License:

  • 10 developers
  • 10 locations
  • 10 projects
  • Perpetual license

This package 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 on 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 $999 per year.

Unlimited License:

  • Unlimited developers
  • Unlimited locations
  • Unlimited projects
  • Perpetual 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 without purchasing additional coverage.

Pricing: Starts from $2999 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 also 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 $ 1599 per year.

Uninterrupted product support and updates: this allows you to access product updates, security feature upgrades, and support from our engineering team.

Pricing: Starts from $ 399 per year.

Create a QR Code in C#

Spire Barcode License Model and Price:

Support is paid and all the subscription is one time Only OEM subscription works for public-facing websites and cloud-based applications.

Developer Subscription:

  • One Developer
  • One Deployment Location

This package authorizes one developer to utilize the product to create an unlimited number of applications that can be deployed at one geographical location within your organization (internal use only). It does not allow the distribution of your custom applications to third parties, public-facing websites, or SaaS/PaaS/IaaS projects.

Pricing: Starts from $898 per year.

Developer OEM Subscription:

  • One Developer
  • Unlimited Deployment Locations

This package authorizes one developer to create an unlimited of custom applications using the product, and the applications are allowed to be distributed in any form to any number of geographic locations.

Pricing: Starts from $3395 per year.

Site Enterprise Subscription:

  • Up to 10 Developers
  • Up to 10 Deployment Locations

This authorizes up to 10 developers to create an unlimited number of applications that can be deployed at up to 10 geographic locations. It does not allow the distribution of your custom applications to public-facing websites, or SaaS/PaaS/IaaS projects.

Pricing: Starts from $5301 per year.

Site OEM Subscription:

  • Up to 50 Developers
  • Unlimited Deployment Locations

This authorizes up to 50 developers to create an unlimited number of custom applications using a product, and the applications are allowed to be distributed in any form to any number of geographic locations.

Pricing: Starts from $10187 per year.

The IronBarcode Lite package includes one developer package with one year of support, and costs around $749, while the Spire Developer OEM Subscription including one developer package costs $3394. With all updates, major releases, and technical support for 1 year, and without releases and technical support cost $1695. The IronPDF Professional package including 10 developer packages, and one year of support costs $999, while the Spire Site OEM Subscription including 10 developer packages costs $10187.00 per year With all updates, major releases, and technical support for 1 year and without releases and updates cost $6558.00.

Both the IronPDF Lite and Professional packages have SaaS service or OEM, as well as a five-year support option. The Lite version includes one developer package with five-year support and with SaaS and OEM service cost $2897USD. while Spire has SaaS service or OEM and a one-year support option. The IronPDF Professional version including a 10-developer package with five years of support and SaaS and OEM service costs $3397, while the Spire package for 10 developers with one year of support and with SaaS and OEM service costs $10187.00

Conclusion

IronBarcode is used to generate enterprise-level barcode formats of barcode images. It also enables developers to rotate barcode images, as well as create barcode image borders to assist further in formatting barcode images. IronBarcode provides reliable barcode generation when compared to other generators, and it generates high-quality barcode images. In short, we can get our desired output image format with IronBarcode. The barcode images that are generated by IronBarcode are best due to we may create, style, and export a barcode with a single line of code. barcode developers easy integration with other net applications and provide the different barcode types it can recognize barcode and postal barcodes easily. The component model of the library is also more efficient — each component mode enables developers to generate barcodes with different styles and different formats. The code is very simple and it's just one line. The recognition component and recognition functionality are better in IronBarcode. The API mode makes it more reliable than the other generators.

Spire.Barcode for .NET provides a way to integrate barcode processing. With just one line of code we can create barcodes and read 1D & 2D barcodes. Spire.BarCode supports variable common image formats, such as Bitmap, JPG, PNG, EMF, TIFF, GIF, and WMF. We can therefore create barcode images, and barcode image developers can easily add barcode generation and make barcodes with just a few lines of code.

IronBarcode packages provide better licenses and support compared to Spire.Barcode, and Spire is more expensive. IronBarcode starts from $749 while Spire.Barcode starts from $898, so IronBarcode is clearly more cost-effective than Spire. IronBarcode also provides more features than Spire.Barcode. It also provides better support and a money-back guarantee, which Spire does not. IronBarcode offers long-term support and is easily integrated with API mode .NET applications. It is easy to integrate with a new document (C, VB.NET and C#), and it also generates multiple barcodes of code.

So, what are you waiting for? Get the free trial! You can obtain the License here and begin straightaway.