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
On-demand generation of new and varied barcodes is a crucial aspect of many commercial .NET Applications. The IronBarcode library makes doing this very quick, convenient, and easy when compared to other third-party options. This tutorial aims to illustrate how this is so.
BarcodeReader
Open Visual Studio and go to the File menu. Select New Project, and then select Console Application/Windows Forms/WPF Application. Barcodes can also be used on all types of applications. Further, you can use them with apps such as Webform/MVC/MVC Core.
Configure your new project
Enter the project name and select the file path in the appropriate text box in Visual Studio. Next, click the Create button, and also select the required .NET Framework. The project will now generate the structure for the selected application. If you have selected the Console Application, it will now open the program.cs
file where you can enter the code and build/run the application.
Now go to the Solution Explorer in Visual Studio and left-click the project. From the pop-up menu, select the NuGet Package Manager from the menu and search for "Barcode" as a keyword. Select the first result in the NuGet Package dialog and click the install option.
Install IronBarcode library from NuGet Package Manager
Alternatively, in Visual Studio follow these instructions: Go to Tools > NuGet Package Manager > Package Manager Console
Open the Package Manager Console tab. Type the line below:
Install-Package IronQR
NuGet Package Manager Console
Go to the following link to learn more about the latest version of the Barcode Reader SDK.
https://www.nuget.org/packages/Barcode
Next, the package will download all the DLL files and also add the reference of the DLL file in the current project as a .NET project reference.
The Visual Studio project is now ready to use with the code.
Add the IronBarCode
reference to the code as shown below, allowing the use of functions available in the IronBarcode library in .NET Core. To learn more about the barcode reader control, reading QR codes, components, support for QR code types, and the compatibility of the barcode reader SDK, please refer to this link: https://ironsoftware.com/csharp/barcode/
using IronBarCode;
using IronBarCode;
BarcodeReader
is the static class that is used to read/create QR codes. It can be used without creating any object instance for the static class BarcodeReader
. The barcode reader control offers the ability to scan 15 types of barcodes using a single function Read
or ReadAsync
. The IronBarcode library enables the reading of QR codes/barcodes from various sources:
String
QR codes and barcode images can be read easily using the .NET barcode reader library. The Read
method is a static function that will scan QR code images and decode QR codes and barcodes into text. It accepts various types of image files like bitmap, PNG files, JPEG, TIFF, etc.
This Read
function extracts QR code/barcode data from the image and retrieves the result as the object BarcodeResult
. If the image file is not recognized by the code, it will return null.
The BarcodeResult
has the following values:
BarcodeType
is an enum data type and it returns the type of the barcode of the given input image. There are twenty-two barcode types supported by IronBarcode. It will return the type of barcode, which is applied to the given input image.
Value and text are also object-type values available on the BarcodeResult
. Both value and text are string data types. That returns the string value of the barcode. Read
method will read QR codes and barcodes and get the string value of the given barcode image into value/text. The binary value is the byte data type and returns the byte of the given image. Below is the quick response code which can be used in any .NET Windows Forms or .NET Standard Applications.
// Read a barcode from an image file
BarcodeResult result = BarcodeReader.Read("test.bmp");
// Check if the result is not null and matches the expected text
if (result != null && result.Text == "https://ironsoftware.com/csharp/barcode")
{
System.Console.WriteLine("Success");
}
// Read a barcode from an image file
BarcodeResult result = BarcodeReader.Read("test.bmp");
// Check if the result is not null and matches the expected text
if (result != null && result.Text == "https://ironsoftware.com/csharp/barcode")
{
System.Console.WriteLine("Success");
}
The above code demonstrates how to read QR codes and barcodes using the .NET barcode reader library. The code is straightforward to use, mapping a file from the system to a Bitmap object. It also decodes the QR code/barcode from the image and displays the result in the object. Below are the QR codes/barcodes provided in the code to scan for the encoded data.
The barcode input
The .NET barcode reader control allows the reading of multiple QR codes/barcodes from an image file using the same Read
method, which is very easy to use.
Below is the sample code for reading multiple QR codes from the image:
// Configure barcode reader options
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
ExpectBarcodeTypes = BarcodeEncoding.Code128,
ExpectMultipleBarcodes = true,
};
// Read multiple barcodes from a TIFF image
BarcodeResult[] multiFrameResults = BarcodeReader.Read("Multiframe.tiff", options);
// Configure barcode reader options
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
ExpectBarcodeTypes = BarcodeEncoding.Code128,
ExpectMultipleBarcodes = true,
};
// Read multiple barcodes from a TIFF image
BarcodeResult[] multiFrameResults = BarcodeReader.Read("Multiframe.tiff", options);
In the above code, QR codes are extracted from TIFF QR code images. The .NET barcode reader scans QR codes from the image from the system and returns the result as an array. In the above code, the barcode for Code128
is the only type scanned. If there are any other barcodes present on the image, they will be ignored.
This section demonstrates how to read the QR code from PDF documents. The QR code library will scan all the available pages and files for all the available QR codes, or focus on one specific type of barcode. When using IronBarcode, the library provides all relevant DLLs needed for a standard barcode reader, so there is no need to include any other DLL as a .NET project reference.
Below is the sample code which can be used to read QR codes/barcodes from PDF.
// Read barcodes from each page of a PDF document
PagedBarcodeResult[] pagedResults = BarcodeReader.ReadPdf("MultipleBarcodes.pdf");
// Process results for each page
foreach (PagedBarcodeResult pageRes in pagedResults)
{
int pageNumber = pageRes.PageNumber;
string value = pageRes.Value;
Bitmap img = pageRes.BarcodeImage;
BarcodeEncoding barcodeType = pageRes.BarcodeType;
byte[] binary = pageRes.BinaryValue;
Console.WriteLine(pageRes.Value);
}
// Read barcodes from each page of a PDF document
PagedBarcodeResult[] pagedResults = BarcodeReader.ReadPdf("MultipleBarcodes.pdf");
// Process results for each page
foreach (PagedBarcodeResult pageRes in pagedResults)
{
int pageNumber = pageRes.PageNumber;
string value = pageRes.Value;
Bitmap img = pageRes.BarcodeImage;
BarcodeEncoding barcodeType = pageRes.BarcodeType;
byte[] binary = pageRes.BinaryValue;
Console.WriteLine(pageRes.Value);
}
The above is the sample code to read QR codes/barcodes from a PDF file from a simple ReadPdf
method. It can also provide detailed results for each barcode and its type.
.NET Barcode readers provide a simple and easy way to read QR codes or decode/create QR codes and barcodes with simple steps. IronBarcode DLL can be used on various environments like .NET Windows Forms Applications, Mobile Apps, Web Applications, MAUI, and Blazor using the .NET Framework or .NET Standard. Additionally, IronBarcode offers a wide range of customization options to improve barcode reading speed, such as crop regions or multi-threading, and the accuracy of the ML model. IronBarcode offers a free trial key, or you can currently buy five products from Iron Software for the price of just two.
Visit the licensing page for more information.
You can also download a zip file project.
IronQR is Iron Software's .NET QR Code library that uses machine learning techniques to read QR codes with high accuracy and allows easy QR code generation and customization.
To get started, download and install the IronBarcode library via NuGet Package Manager in Visual Studio, and add relevant references in your C# project.
Yes, IronBarcode can read multiple barcodes from an image using the Read method with options configured to expect multiple barcodes.
QR code integration using IronBarcode is supported in various application types, including Console Application, Windows Forms, WPF Application, Webform, MVC, and MVC Core.
You can read QR codes from a PDF document using the ReadPdf method, which scans each page for QR codes and returns detailed results.
IronBarcode supports reading 22 different barcode types, including QR codes and Code128, among others.
Yes, IronBarcode is designed to be quick, convenient, and easy to use, making it suitable for commercial .NET applications that require reliable barcode reading.
Yes, IronBarcode offers various customization options to improve barcode reading speed and accuracy, such as setting crop regions, multi-threading, and adjusting the accuracy of the ML model.
IronBarcode is compatible with .NET Windows Forms Applications, Mobile Apps, Web Applications, MAUI, and Blazor using .NET Framework or .NET Standard.
For more information about licensing IronBarcode, you can visit the licensing page on the Iron Software website.