IronBarcode 操作指南 读取多个条形码 How to Read Multiple Barcodes at Once Hairil Hasyimi Bin Omar 已更新:七月 22, 2025 Download IronBarcode NuGet 下载 DLL 下载 Start Free Trial Copy for LLMs Copy for LLMs Copy page as Markdown for LLMs Open in ChatGPT Ask ChatGPT about this page Open in Gemini Ask Gemini about this page Open in Grok Ask Grok about this page Open in Perplexity Ask Perplexity about this page Share Share on Facebook Share on X (Twitter) Share on LinkedIn Copy URL Email article This article was translated from English: Does it need improvement? Translated View the article in English Reading multiple barcodes simultaneously is crucial for various industries, including logistics, retail, healthcare, and inventory management, as it enables efficient data processing. With IronBarcode, you can easily achieve this capability, making it a powerful tool for streamlining operations and enhancing productivity. Quickstart: Read All Barcodes from an Image Easily This example shows how quickly you can use IronBarcode to scan an image for every barcode contained within it. Just set ExpectMultipleBarcodes = true alongside the barcode types you want — no boilerplate, no hassle. Get started making PDFs with NuGet now: Install IronBarcode with NuGet Package Manager PM > Install-Package BarCode Copy and run this code snippet. var results = IronBarCode.BarcodeReader.Read("image.png", new IronBarCode.BarcodeReaderOptions { ExpectMultipleBarcodes = true, ExpectBarcodeTypes = IronBarCode.BarcodeEncoding.AllOneDimensional }); Deploy to test on your live environment Start using IronBarcode in your project today with a free trial Free 30 day Trial Minimal Workflow (5 steps) Download the C# library to read multiple barcodes Use the Read method to extract barcode values from various image formats Utilize the ExpectMultipleBarcodes property to configure reading of single or multiple barcodes Set the ExpectMultipleBarcodes property to false to increase performance Print out the barcode values Read Multiple Barcodes Example 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 in the image. To address this, users can customize the settings to enable reading multiple barcodes, as shown in the code snippet below. Please note that the ExpectMultipleBarcodes property exists in both the BarcodeReaderOptions and PdfBarcodeReaderOptions classes, allowing users to use it for reading barcodes in both images and PDF documents. Sample Image :path=/static-assets/barcode/content-code-examples/how-to/read-multiple-barcodes-read-multiple-barcodes.cs 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()); } Imports IronBarCode Imports System ' Set the option to read multiple barcodes Private options As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = True, .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional } ' Read barcode Private results = BarcodeReader.Read("testbc1.png", options) For Each result In results Console.WriteLine(result.ToString()) Next result $vbLabelText $csharpLabel By setting ExpectMultipleBarcodes to true in the code snippet, IronBarcode scans the entire document for multiple barcodes and stores them in the BarcodeResults variable. Using a foreach loop, users can easily access and print all the barcode values to the console. Reading Single Barcode Example IronBarcode can read both single and multiple barcodes in an image or PDF. By default, the engine scans the entire document even if there is only one barcode. However, for increased performance when reading a single barcode, you can set ExpectMultipleBarcodes to false. This stops the engine from scanning the entire document after the first barcode is detected, resulting in faster barcode retrieval. The code snippet below demonstrates how to do this. Sample Image :path=/static-assets/barcode/content-code-examples/how-to/read-multiple-barcodes-read-single-barcode.cs 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()); } Imports IronBarCode Imports System ' Set the option to read single barcode Private options As New BarcodeReaderOptions() With { .ExpectMultipleBarcodes = False, .ExpectBarcodeTypes = BarcodeEncoding.AllOneDimensional } ' Read barcode Private results = BarcodeReader.Read("testbc1.png", options) For Each result In results Console.WriteLine(result.ToString()) Next result $vbLabelText $csharpLabel In the code snippet above, we used the same image with multiple barcodes as before, but this time, we 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. Performance Comparison Setting ExpectMultipleBarcodes to false can greatly improve the efficiency of reading single barcodes in the image. Using the provided code snippet, here's a rough estimate of the performance difference between setting ExpectMultipleBarcodes to true and false on the same machine: ExpectMultipleBarcodes = true ExpectMultipleBarcodes = false 00.91 second 00.10 second 常见问题解答 如何用 C# 读取图像中的多个条形码? 要使用 C# 读取图像中的多个条形码,可以在 BarcodeReaderOptions 或 PdfBarcodeReaderOptions 类中将 IronBarcode 的 Read 方法与 ExpectMultipleBarcodes 属性设置为 true。 在 IronBarcode 中将 ExpectMultipleBarcodes 设置为 true 的好处是什么? 将 ExpectMultipleBarcodes 设置为 true 允许 IronBarcode 扫描和读取图像中存在的所有条形码,这对于需要同时处理多个条形码以提高数据效率的行业至关重要。 我可以在读取单个条形码时提高性能吗? 是的,通过在 IronBarcode 中将 ExpectMultipleBarcodes 设置为 false,您可以提高性能。这将在检测到第一个条形码后停止扫描过程,从而实现更快的检索时间。 如何用 C# 从 PDF 文档读取条形码? IronBarcode 提供功能以使用 Read 方法从 PDF 文档读取条形码,并在 PdfBarcodeReaderOptions 中配置适当的选项。 如果在检测到多个条形码时只检测到一个怎么办? 确保在 IronBarcode 中将 ExpectMultipleBarcodes 属性设置为 true,以启用图像或 PDF 中所有条形码的检测和读取。 如何配置 IronBarcode 以便从各种图像格式读取条形码? 要配置 IronBarcode 以读取各种图像格式的条形码,您应使用 Read 方法,并在 BarcodeReaderOptions 类中设置 ExpectMultipleBarcodes 属性。 使用 ExpectMultipleBarcodes 设置为 true 和 false 时的性能差异是什么? 性能差异显著;将 ExpectMultipleBarcodes 设置为 false 会减少处理时间,因为它在检测到第一个条形码后停止扫描,而设置为 true 则扫描所有条形码,这需要更长时间。 是否有用于有效读取多个条形码的 C# 库? 是的,IronBarcode 是一个 C# 库,允许从图像和 PDF 文档中有效读取多个条形码,并提供改善性能和简化数据处理的工具。 Hairil Hasyimi Bin Omar 立即与工程团队聊天 软件工程师 如所有伟大的工程师一般,Hairil 是个热心的学习者。他正在提高对 C#、Python 和 Java 的知识,并利用这些知识为 Iron Software 团队成员增值。Hairil 从马来西亚的玛拉工业大学加入 Iron Software 团队,获得化学与工艺工程学士学位。 准备开始了吗? Nuget 下载 1,935,276 | 版本: 2025.11 刚刚发布 免费 NuGet 下载 总下载量:1,935,276 查看许可证