IRONSOFTWAREHOME

How to Read Multiple Barcodes at Once in C#

Hairil Hasyimi Bin Omar
Hairil Hasyimi Bin Omar
Updated: August 2, 2026

IronBarcode enables simultaneous reading of multiple barcodes from images and PDFs by setting ExpectMultipleBarcodes = true, streamlining data processing for logistics, retail, and inventory management applications. Whether building warehouse systems, retail point-of-sale applications, or document processing solutions, IronBarcode's advanced reading capabilities provide the reliability and performance you need.

Quickstart: Read All Barcodes from an Image Easily

This example shows how quickly you can use IronBarcode to scan an image for every barcode it contains. Just set ExpectMultipleBarcodes = true alongside the barcode types you want - no boilerplate, no hassle.

  1. 1Install IronBarcode with NuGet Package Manager

    PM > Install-Package BarCode

  2. 2Copy and run this code snippet.

    var results = IronBarCode.BarcodeReader.Read("image.png", new IronBarCode.BarcodeReaderOptions { ExpectMultipleBarcodes = true, ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.AllOneDimensional });
    C#
  3. 3Deploy to test on your live environment

    Start using IronBarcode in your project today with a free trial
    arrow pointer

How Do I Read Multiple Barcodes from an Image?

By default, IronBarcode continuously scans a document to read multiple barcodes. However, there have been instances where only one barcode value is returned, even when multiple barcodes are present. To address this, customize the settings to enable reading multiple barcodes, as shown below. The ExpectMultipleBarcodes property exists in both BarcodeReaderOptions and PdfBarcodeReaderOptions classes, allowing you to use it for reading barcodes in both images and PDF documents.

Three sample barcodes labeled A, B, and C showing different bar patterns for multi-barcode reading demonstration
using IronBarCode;
using System;

// Set the option to read multiple barcodes
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    ExpectMultipleBarcodes = true,
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
};

// Read barcode
var results = BarcodeReader.Read("testbc1.png", options);

foreach (var result in results)
{
    Console.WriteLine(result.ToString());
}

Setting ExpectMultipleBarcodes to true enables IronBarcode to scan the entire document for multiple barcodes and store them in the BarcodeResults variable. Using a foreach loop, you can easily access and print all barcode values to the console.

Advanced Multiple Barcode Reading Scenarios

When working with multiple barcodes, you might encounter scenarios that require additional configuration. Here's a comprehensive example demonstrating how to read multiple barcodes with different formats from a complex document:

using IronBarCode;
using System;
using System.Linq;

// Configure advanced options for mixed barcode types
BarcodeReaderOptions advancedOptions = new BarcodeReaderOptions()
{
    ExpectMultipleBarcodes = true,
    // Read both 1D and 2D barcodes
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional | BarcodeEncoding.QRCode | BarcodeEncoding.DataMatrix,
    // Apply image correction filters for better accuracy
    ImageFilters = new ImageFilterCollection() {
        new SharpenFilter(),
        new ContrastFilter()
    },
    // Set speed vs accuracy balance
    Speed = ReadingSpeed.Balanced
};

// Read barcodes from the image
var imageResults = BarcodeReader.Read("mixed-barcodes.jpg", advancedOptions);

// Process results with error handling
foreach (var result in imageResults)
{
    Console.WriteLine($"Barcode Type: {result.BarcodeType}");
    Console.WriteLine($"Value: {result.Value}");
    Console.WriteLine($"Page: {result.PageNumber}");
    Console.WriteLine("---");
}
C#

This advanced example showcases several important features:

How Can I Read a Single Barcode for Better Performance?

IronBarcode reads both single and multiple barcodes in images or PDFs. By default, the engine scans the entire document even if only one barcode exists. For increased performance when reading a single barcode, set ExpectMultipleBarcodes to false. This stops the engine from scanning the entire document after detecting the first barcode, resulting in faster barcode retrieval. The code below demonstrates this approach.

Three identical sample barcodes labeled A, B, and C for barcode reading demonstration
using IronBarCode;
using System;

// Set the option to read single barcode
BarcodeReaderOptions options = new BarcodeReaderOptions()
{
    ExpectMultipleBarcodes = false,
    ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional,
};

// Read barcode
var results = BarcodeReader.Read("testbc1.png", options);

foreach (var result in results)
{
    Console.WriteLine(result.ToString());
}

In this example, we used the same image with multiple barcodes as before but set ExpectMultipleBarcodes to false. As a result, only the first barcode value is returned, and the scanning process stops once the first barcode is retrieved.

Optimizing Single Barcode Reading with Crop Regions

For even better performance when reading single barcodes, combine the ExpectMultipleBarcodes = false setting with crop region specifications. This technique is particularly useful when you know the approximate location of your barcode:

using IronBarCode;
using IronSoftware.Drawing;

// Define a crop region where the barcode is likely located
var cropRegion = new Rectangle(100, 100, 300, 200);

// Configure options for optimal single barcode reading
BarcodeReaderOptions optimizedOptions = new BarcodeReaderOptions()
{
    ExpectMultipleBarcodes = false,
    ExpectBarcodeTypes = BarcodeEncoding.Code128,
    CropArea = cropRegion,
    Speed = ReadingSpeed.Faster
};

// Read with optimized settings
var result = BarcodeReader.Read("product-label.png", optimizedOptions).FirstOrDefault();

if (result != null)
{
    Console.WriteLine($"Barcode found: {result.Value}");
}
C#

How Much Faster Is Single Barcode Reading?

Setting ExpectMultipleBarcodes = false greatly improves the efficiency of reading single barcodes. The performance gain is particularly noticeable when working with high-resolution images or when implementing asynchronous barcode reading in high-throughput applications.

Setting ExpectMultipleBarcodes = false lets the engine stop after detecting the first barcode instead of scanning the entire document, which can noticeably reduce read time for single-barcode workloads. The actual performance gain varies based on:

  • Image resolution and complexity
  • Number of barcodes present in the image
  • Selected barcode formats
  • Applied image filters
  • Hardware specifications

Best Practices for Multiple Barcode Reading

When implementing multiple barcode reading in production applications, consider these best practices:

  1. Specify Expected Barcode Types: Instead of using BarcodeEncoding.All, specify only the formats you expect. This significantly improves performance.
  2. Use Appropriate Image Formats: For best results, use high-contrast images. Learn more about creating optimal barcode images.
  3. Handle Imperfect Barcodes: Real-world barcodes may be damaged or poorly printed. Use image correction techniques to improve reading success rates.
  4. Stream Processing: For large batches, consider reading from streams to optimize memory usage.
  5. Error Handling: Always implement proper error handling for scenarios where barcodes cannot be read:
try
{
    var results = BarcodeReader.Read("barcodes.png", new BarcodeReaderOptions 
    { 
        ExpectMultipleBarcodes = true 
    });
    
    if (!results.Any())
    {
        Console.WriteLine("No barcodes found in the image");
    }
    else
    {
        Console.WriteLine($"Found {results.Count()} barcodes");
    }
}
catch (Exception ex)
{
    Console.WriteLine($"Error reading barcodes: {ex.Message}");
    // Log error for debugging
}

By following these practices and utilizing IronBarcode's comprehensive features, you can build robust applications that efficiently handle multiple barcode reading scenarios across various industries and use cases.

Frequently Asked Questions

How do I enable multiple barcode scanning in IronBarcode?

To enable multiple barcode scanning in IronBarcode, set the 'ExpectMultipleBarcodes' property to true within the BarcodeReaderOptions or PdfBarcodeReaderOptions classes.

What is the purpose of the ExpectMultipleBarcodes property in IronBarcode?

The 'ExpectMultipleBarcodes' property allows IronBarcode to read multiple barcodes from an image or PDF simultaneously, optimizing data extraction in logistics and retail applications.

Can IronBarcode read both 1D and 2D barcodes?

Yes, IronBarcode can read both 1D and 2D barcodes. You can specify the types of barcodes to expect by configuring the 'ExpectBarcodeTypes' property in BarcodeReaderOptions.

How do I increase the performance for reading only one barcode using IronBarcode?

To increase performance when reading a single barcode, set 'ExpectMultipleBarcodes' to false in the BarcodeReaderOptions. This stops the scanning process after detecting the first barcode.

What configurations are available for reading multiple barcodes with different formats?

IronBarcode offers advanced options like combining different barcode decoding types, applying image correction filters, and adjusting reading speed for handling multiple barcode formats.

How can image correction enhance barcode reading in IronBarcode?

Applying image correction filters, such as the SharpenFilter and ContrastFilter, can enhance barcode reading accuracy by compensating for poor image quality or damaged barcodes.

What strategies are recommended for optimal barcode reading performance?

For optimal performance, specify expected barcode types, use high-contrast images, implement image correction techniques, read from streams for large batches, and include error handling.

How can I handle errors while reading barcodes with IronBarcode?

Implement proper error handling using try-catch blocks to manage scenarios where barcodes cannot be read, and log errors for debugging if necessary.

Is stream processing supported in IronBarcode for large barcode batches?

Yes, IronBarcode supports reading barcodes from streams, which is particularly useful for optimizing memory usage in high-throughput applications or large batch processing.

Ready to Get Started?

Nuget Downloads 2,422,100Version:2026.9just released

Get your FREE

30-day Trial Key instantly.

bullet_checkedNo credit card or account creation required
bullet_testTest in production
without watermarks
bullet_calendar30 days fully
functional product
bullet_support24/5 technical
support during trial
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package BarCode
nuget.org/packages/BarCode/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronBarCode"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

  1. Download and unzip IronBarCode to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronBarCode.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required