Skip to footer content
USING IRONBARCODE

Barcode .NET Component Tutorial Using IronBarcode

A barcode .NET component is a managed code library that lets you generate and read barcodes in C# applications with just a few lines of code. IronBarcode supports all major symbologies -- Code 128, QR, Data Matrix, EAN, UPC, and more -- and runs on Windows, Linux, and macOS without additional runtime dependencies.

Install via NuGet and start generating barcodes in minutes:

Install-Package BarCode
Install-Package BarCode
SHELL

What Is a Barcode .NET Component?

A barcode .NET component is a software library packaged as a NuGet package that provides barcode generation and reading capabilities through a clean API. Unlike barcode fonts, which require manual checksum calculations and complex formatting rules, a dedicated component handles all encoding logic internally.

The IronBarcode library exposes two primary entry points:

  • BarcodeWriter -- creates barcode images, PDFs, and HTML from text or numeric data
  • BarcodeReader -- scans images, PDFs, and multi-frame TIFFs to extract barcode values

This bidirectional design means you can both print barcodes onto labels and scan them back from documents within the same library, which is essential for inventory management, document tracking, Crystal Reports integration, and data automation workflows.

Supported symbologies include:

  • 1D linear: Code 128, Code 39, Code 93, ITF-14, EAN-13, EAN-8, UPC-A, UPC-E
  • 2D matrix: QR Code, Data Matrix, PDF417, Aztec
  • GS1 variants: GS1-128, GS1 DataBar

Manufacturing systems typically use Code 128 for product tracking because it encodes alphanumeric data efficiently. Healthcare applications commonly rely on Data Matrix for medication labeling because it prints well at very small sizes. Retail point-of-sale systems scan EAN-13 and UPC-A barcodes at checkout. Choosing the right symbology for your use case is one of the first decisions you will make when integrating barcode functionality.

How Do You Install IronBarcode in a .NET Project?

Installing IronBarcode takes under two minutes using the NuGet Package Manager in Visual Studio or the .NET CLI.

Package Manager Console (Visual Studio):

Install-Package BarCode
Install-Package BarCode
SHELL

.NET CLI:

dotnet add package BarCode
dotnet add package BarCode
SHELL

How to Integrate a Barcode .NET Component in C#: Figure 3 - Installation

After the package installs, add the namespace at the top of any file that uses barcode functionality:

using IronBarCode;
using IronBarCode;
$vbLabelText   $csharpLabel

IronBarcode targets .NET Framework 4.6.2 and later, .NET Core 3.1 and later, and .NET 5 through .NET 10. It runs on Windows, Linux, and macOS, so the same code works across cloud-hosted containers, on-premises servers, and developer workstations without platform-specific configuration.

For ASP.NET Core applications, no middleware registration is required. You call the API directly from controllers, background services, or Razor Pages. Windows Forms and WPF applications gain access the same way -- add the namespace and start calling methods.

How to Integrate a Barcode .NET Component in C#: Figure 4 - Generate Barcodes with Cross Platform Support

Detailed installation steps, including offline NuGet feed configuration and proxy settings, are available in the IronBarcode getting started guide.

How Do You Generate a Barcode Image in C#?

Generating a barcode with IronBarcode requires three steps: choose the encoding, set the value, and save the output. The following example creates a Code 128 barcode and saves it as both a PNG image and a PDF document:

using IronBarCode;

// Create a Code 128 barcode encoding a product identifier
var barcode = BarcodeWriter.CreateBarcode("PRD-12345-2024", BarcodeEncoding.Code128);

// Set the output dimensions in pixels
barcode.ResizeTo(400, 100);

// Add human-readable text beneath the bars
barcode.AddBarcodeValueTextBelowBarcode();

// Export to PNG for screen display and label printing
barcode.SaveAsImage("product-barcode.png");

// Export to PDF for document embedding
barcode.SaveAsPdf("product-barcode.pdf");
using IronBarCode;

// Create a Code 128 barcode encoding a product identifier
var barcode = BarcodeWriter.CreateBarcode("PRD-12345-2024", BarcodeEncoding.Code128);

// Set the output dimensions in pixels
barcode.ResizeTo(400, 100);

// Add human-readable text beneath the bars
barcode.AddBarcodeValueTextBelowBarcode();

// Export to PNG for screen display and label printing
barcode.SaveAsImage("product-barcode.png");

// Export to PDF for document embedding
barcode.SaveAsPdf("product-barcode.pdf");
$vbLabelText   $csharpLabel

The ResizeTo() method sets pixel dimensions precisely, which matters when you are printing labels at a specific DPI. The AddBarcodeValueTextBelowBarcode() call adds human-readable text under the bars, making manual verification easier in warehouse and retail environments.

Barcode Output Formats

How to Integrate a Barcode .NET Component in C#: Figure 5 - PNG Output

How to Integrate a Barcode .NET Component in C#: Figure 6 - PDF Output

IronBarcode exports to PNG, JPEG, GIF, TIFF, BMP, PDF, HTML, and base64 strings. The base64 format is particularly useful for embedding barcodes in API responses that a frontend renders dynamically without writing files to disk.

How Do You Generate a QR Code in C#?

For QR codes, IronBarcode provides the QRCodeWriter class with built-in support for error correction levels and module size control:

using IronBarCode;

// Generate a QR code from a URL with 500px dimensions
var qrCode = QRCodeWriter.CreateQrCode("https://example.com/product/12345", 500);

// Save the QR code to a PNG file
qrCode.SaveAsImage("product-qr.png");
using IronBarCode;

// Generate a QR code from a URL with 500px dimensions
var qrCode = QRCodeWriter.CreateQrCode("https://example.com/product/12345", 500);

// Save the QR code to a PNG file
qrCode.SaveAsImage("product-qr.png");
$vbLabelText   $csharpLabel

QR codes can encode URLs, plain text, vCard contact data, Wi-Fi credentials, and arbitrary byte sequences. The barcode generation examples page covers additional encoding scenarios including Data Matrix and PDF417.

How Do You Read Barcodes from Images?

Reading barcodes from an image is as direct as writing them. The BarcodeReader.Read() method accepts a file path, Stream, Bitmap, or IronSoftware.Drawing.AnyBitmap, and returns a BarcodeResults collection:

using IronBarCode;

// Read all barcodes from a scanned document image
BarcodeResults results = BarcodeReader.Read("scanned-document.png");

// Iterate over every detected barcode
foreach (BarcodeResult result in results)
{
    string value = result.Value;
    BarcodeEncoding type = result.BarcodeType;
    Console.WriteLine($"Detected {type}: {value}");
}
using IronBarCode;

// Read all barcodes from a scanned document image
BarcodeResults results = BarcodeReader.Read("scanned-document.png");

// Iterate over every detected barcode
foreach (BarcodeResult result in results)
{
    string value = result.Value;
    BarcodeEncoding type = result.BarcodeType;
    Console.WriteLine($"Detected {type}: {value}");
}
$vbLabelText   $csharpLabel

The reader automatically preprocesses images to correct common scanning problems: rotation, skew, noise, low contrast, and perspective distortion. This means you can pass raw scanner output directly without pre-processing it yourself.

Scanning from a Real Document

How to Integrate a Barcode .NET Component in C#: Figure 7 - Code128 barcode ready for scanning

Reading Output

How to Integrate a Barcode .NET Component in C#: Figure 8 - Barcode Output

How Do You Configure Barcode Reading Options?

For high-volume or challenging scanning scenarios, BarcodeReaderOptions gives you fine-grained control over the reading algorithm:

using IronBarCode;

var options = new BarcodeReaderOptions
{
    // Balance accuracy and processing time
    Speed = ReadingSpeed.Balanced,

    // Detect multiple barcodes in one pass
    ExpectMultipleBarcodes = true,

    // Limit the search to 1D formats for faster processing
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional
};

// Read from a multi-page PDF warehouse inventory report
var results = BarcodeReader.Read("warehouse-inventory.pdf", options);
using IronBarCode;

var options = new BarcodeReaderOptions
{
    // Balance accuracy and processing time
    Speed = ReadingSpeed.Balanced,

    // Detect multiple barcodes in one pass
    ExpectMultipleBarcodes = true,

    // Limit the search to 1D formats for faster processing
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional
};

// Read from a multi-page PDF warehouse inventory report
var results = BarcodeReader.Read("warehouse-inventory.pdf", options);
$vbLabelText   $csharpLabel

Setting ExpectBarcodeTypes to match the formats you actually expect improves throughput because the reader skips patterns that cannot match. The Speed property ranges from Faster (best for clean, high-quality images) to ExtremeDetail (best for damaged or low-resolution sources). The barcode reading documentation covers additional options including multi-threading and region-of-interest scanning.

How Do You Customize Barcode Appearance?

IronBarcode lets you control every visual aspect of a generated barcode before saving it. You can set colors, fonts, margins, and annotation text programmatically. This is useful when generating barcodes for branded labels or regulated industries where label layout follows strict specifications.

The API follows a fluent-style pattern: create the barcode, call style methods, then save. All style properties affect the output immediately and do not require a separate render step. See the styling and annotation examples for the full list of available properties.

How Do You Handle Barcodes in PDF Documents?

IronBarcode reads barcodes embedded in PDF files the same way it reads image files. Pass a PDF path to BarcodeReader.Read() and the library extracts barcodes from every page automatically. This is valuable for accounts payable workflows where invoice PDFs contain GS1-128 barcodes, and for logistics systems where shipping manifests are distributed as PDF attachments.

You can also write barcodes directly into PDF pages using IronBarcode alongside IronPDF for document generation. A common pattern is to generate a shipping label PDF that contains both a human-readable address block and a scannable Code 128 barcode for the tracking number.

For further reading on PDF barcode workflows, the IronBarcode tutorials section provides end-to-end examples covering invoice processing, batch label printing, and document archiving.

How Do You Integrate Barcodes into ASP.NET Core APIs?

Returning a barcode image from an ASP.NET Core controller endpoint is a common requirement for web portals that display dynamic labels. IronBarcode's base64 output makes this straightforward:

using IronBarCode;

// In an ASP.NET Core controller action
public IActionResult GetBarcodeImage(string productId)
{
    var barcode = BarcodeWriter.CreateBarcode(productId, BarcodeEncoding.Code128);
    barcode.ResizeTo(400, 100);
    barcode.AddBarcodeValueTextBelowBarcode();

    // Return the barcode as a PNG image response
    byte[] imageBytes = barcode.ToJpegBinaryData();
    return File(imageBytes, "image/jpeg");
}
using IronBarCode;

// In an ASP.NET Core controller action
public IActionResult GetBarcodeImage(string productId)
{
    var barcode = BarcodeWriter.CreateBarcode(productId, BarcodeEncoding.Code128);
    barcode.ResizeTo(400, 100);
    barcode.AddBarcodeValueTextBelowBarcode();

    // Return the barcode as a PNG image response
    byte[] imageBytes = barcode.ToJpegBinaryData();
    return File(imageBytes, "image/jpeg");
}
$vbLabelText   $csharpLabel

This approach works with any frontend framework. The browser receives a standard image response and displays it in an <img> tag. For high-traffic endpoints, generate barcodes once and cache the byte array, since the same product ID always produces the same barcode image.

The IronBarcode API reference documents all available methods including streaming output, which avoids allocating large byte arrays for very high-resolution barcodes.

How Does IronBarcode Handle Barcode Validation and Error Correction?

Barcode standards define strict encoding rules and checksum requirements. Code 128 uses a weighted modulo-103 checksum. EAN-13 uses modulo-10. QR codes embed Reed-Solomon error correction that allows partial data recovery even when up to 30% of the barcode is obscured or damaged.

IronBarcode enforces these rules automatically. When you call BarcodeWriter.CreateBarcode(), the library validates that the data fits the symbology's character set and length constraints, then calculates and appends the correct checksum without any additional steps from your code. This prevents generating invalid barcodes that scanners will reject.

On the reading side, the library applies error correction during decoding, which means it can often recover the correct value from a barcode that is partially torn, smudged, or printed at low resolution. This behavior is particularly important for GS1 barcode standards compliance in retail and logistics.

For a deeper look at how barcode error correction works at the specification level, the ISO/IEC barcode standards documentation provides the authoritative technical reference.

What Are Common Barcode Integration Scenarios?

Common barcode integration scenarios and recommended IronBarcode features
Scenario Symbology Key IronBarcode Feature
Retail point-of-sale EAN-13, UPC-A BarcodeEncoding.EAN13, PDF export
Warehouse inventory Code 128, ITF-14 ExpectMultipleBarcodes = true
Healthcare labeling Data Matrix, GS1-128 Small-size printing, high DPI export
Document tracking PDF417, Code 39 PDF reading, multi-page support
Mobile product lookup QR Code QRCodeWriter.CreateQrCode()
Shipping labels Code 128, GS1-128 Label-size PDF output, text annotation

Each scenario benefits from different configuration choices. The IronBarcode examples gallery provides runnable code for all of the scenarios above.

What Are Your Next Steps?

Integrating a barcode .NET component turns what would otherwise be a weeks-long custom development effort into an afternoon of configuration. IronBarcode handles encoding rules, checksums, image preprocessing, and error correction so your team can focus on the business logic that surrounds barcode workflows rather than the barcode mechanics themselves.

To move forward:

  1. Install the package: dotnet add package BarCode or Install-Package BarCode in the Package Manager Console
  2. Try the quickstart: The barcode quickstart example walks through generation and reading in under 20 lines of code
  3. Explore symbologies: The supported barcode types reference lists all encoding formats with usage guidance
  4. Review pricing: IronBarcode licensing options cover single-developer, team, and OEM redistribution use cases
  5. Start a free trial: Download a 30-day free trial license to evaluate the full feature set in your own application

For questions about enterprise licensing, high-volume deployments, or technical integration challenges, the IronBarcode support team is available to help.

External references for barcode standards and specifications:

Frequently Asked Questions

What is a barcode .NET component?

A barcode .NET component is a software library that enables developers to integrate barcode generation and scanning into .NET applications, handling encoding rules, checksums, and image preprocessing automatically.

How can IronBarcode help in .NET applications?

IronBarcode provides a .NET component for generating and reading barcodes through a simple API, making it straightforward to add barcode capabilities to C# applications without implementing encoding algorithms manually.

What types of barcodes can be generated using IronBarcode?

IronBarcode supports Code 128, Code 39, Code 93, ITF-14, EAN-13, EAN-8, UPC-A, UPC-E, QR Code, Data Matrix, PDF417, Aztec, and GS1 variants.

Why should I use a barcode component instead of creating my own solution?

A professional barcode component handles checksum calculation, error correction, image preprocessing, and multi-format support automatically, reducing development time and the risk of generating invalid barcodes.

Is IronBarcode suitable for data automation tasks?

Yes, IronBarcode is well-suited for data automation. It reads barcodes from images and PDFs and integrates directly into background services, scheduled jobs, and ASP.NET Core APIs.

Can IronBarcode be used for document tracking?

Yes. IronBarcode reads barcodes from multi-page PDF files and multi-frame TIFFs, making it practical for document tracking workflows in logistics, accounts payable, and records management.

What .NET versions does IronBarcode support?

IronBarcode supports .NET Framework 4.6.2 and later, .NET Core 3.1 and later, and .NET 5 through .NET 10, running on Windows, Linux, and macOS.

How does IronBarcode enhance inventory management systems?

IronBarcode provides reliable barcode generation and multi-barcode scanning from images and PDFs, enabling quick and accurate inventory tracking in warehouse and retail environments.

Jordi Bardia
Software Engineer
Jordi is most proficient in Python, C# and C++, when he isn’t leveraging his skills at Iron Software; he’s game programming. Sharing responsibilities for product testing, product development and research, Jordi adds immense value to continual product improvement. The varied experience keeps him challenged and engaged, and he ...
Read More