Class BarcodeReader
A versatile static class for reading many popular barcode formats from images and PDFs.
IronBarCode.BarcodeReader supports barcode reading from Bitmaps, image objects, image files, image streams, multi-frame TIFF images, and PDFs.
Features: Crop-area support, image filters, and pre-processing for improved accuracy, including the ability to automatically un-rotate, deskew and clean barcode image input.
Inheritance
Namespace: IronBarCode
Assembly: IronBarCode.dll
Syntax
public static class BarcodeReader : Object
BarcodeReader decodes barcodes and QR codes from images, byte arrays, streams, and PDF files in C#. A single static call scans a supplied source, locates every symbol it can find, and hands back the decoded text, the symbology, and the position of each code. It is the entry point a developer reaches for behind a search like "C# barcode reader" or "read barcode from image C#", and it covers both one-dimensional barcodes and two-dimensional codes through the same surface.
Because BarcodeReader is a static class, there is no object to construct. Call Read with a file path, an AnyBitmap, a byte array, or a stream, and pass an optional BarcodeReaderOptions to tune detection. For PDF input, call ReadPdf (or ReadPdfs for several documents) with a PdfBarcodeReaderOptions that adds page selection, DPI, and a password. Each read returns a BarcodeResults collection, and ReadAsync and ReadPdfsAsync provide awaitable forms that keep the work off a UI or request thread. The collection overloads accept a sequence of sources so a batch of images or documents runs through one call.
The most-used members group by source. The image lane is Read and ReadAsync, taking a path, AnyBitmap, byte[], or Stream. The PDF lane is ReadPdf, ReadPdfs, and ReadPdfsAsync, taking the same source shapes plus a PdfBarcodeReaderOptions. Detection itself is steered through BarcodeReaderOptions: set ExpectBarcodeTypes to limit the symbologies scanned, ExpectMultipleBarcodes to keep scanning after the first hit, ScanMode to pick a basic or machine-learning strategy, and Speed to trade thoroughness for throughput. BarcodeReader reads from photos, screenshots, and scanned documents, not only crisp generated images, which is why the machine-learning scan modes exist for difficult sources. Iterate the returned BarcodeResults rather than assuming a single code, since one image or PDF page can carry several.
using IronBarCode;
BarcodeResults results = BarcodeReader.Read("barcode.png");
foreach (BarcodeResult result in results)
Console.WriteLine(result.Value);The read barcodes from images how-to walks through image input, the read barcodes from PDF how-to handles documents, and the reading barcodes tutorial covers the full workflow.
Methods
Read(AnyBitmap, BarcodeReaderOptions)
Read barcodes from an image.
Overloads of this method accept the input image as IronSoftware.Drawing.AnyBitmap, as well as System.String file path, array of System.Byte and System.IO.Stream types.
Declaration
public static BarcodeResults Read(AnyBitmap inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Drawing.AnyBitmap | inputImage | The input image as a IronSoftware.Drawing.AnyBitmap. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(Byte[], BarcodeReaderOptions)
Read barcodes from an image.
Overloads of this method accept the input image as an array of System.Byte, as well as IronSoftware.Drawing.AnyBitmap, System.String file paths and System.IO.Stream types.
Declaration
public static BarcodeResults Read(byte[] inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | inputImage | IEnumerable of Binary data of Image as a System.Byte array. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(IEnumerable<AnyBitmap>, BarcodeReaderOptions)
Read barcodes from multiple images.
Reading in parallel should be set by BarcodeReaderOptions.Multithreaded = true. If set to true, multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Overloads of this method accept the input images as an IEnumerable of System.String file paths as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.IO.Stream types.
Declaration
public static BarcodeResults Read(IEnumerable<AnyBitmap> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<IronSoftware.Drawing.AnyBitmap> | inputImages | The input images as an IEnumerable of IronSoftware.Drawing.AnyBitmap. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults | An Array of BarcodeResults. Array length will be zero if no barcodes were found. |
Read(IEnumerable<Byte[]>, BarcodeReaderOptions)
Read barcodes from multiple images.
Reading in parallel should be set by BarcodeReaderOptions.Multithreaded = true. If set to true, multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Overloads of this method accept the input images as an IEnumerable of array of System.Byte, as well as IronSoftware.Drawing.AnyBitmap, string file paths and System.IO.Stream types.
Declaration
public static BarcodeResults Read(IEnumerable<byte[]> inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Byte[]> | inputImage | IEnumerable of binary data of the image as a System.Byte array. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(IEnumerable<Stream>, BarcodeReaderOptions)
Read barcodes from multiple images.
Reading in parallel should be set by BarcodeReaderOptions.Multithreaded = true. If set to true, multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Overloads of this method accept the input images as an IEnumerable of System.IO.Stream, as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.String file path types.
Declaration
public static BarcodeResults Read(IEnumerable<Stream> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.IO.Stream> | inputImages | The input images as an IEnumerable of System.IO.Stream. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(IEnumerable<String>, BarcodeReaderOptions)
Reads barcodes from multiple images.
Reading in parallel should be set by BarcodeReaderOptions.Multithreaded = true. If set to true, multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Overloads of this method accept the input images as an IEnumerable of System.String file paths, as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.IO.Stream types.
Declaration
public static BarcodeResults Read(IEnumerable<string> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | inputImages | The input images as an IEnumerable of string file paths. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(Stream, BarcodeReaderOptions)
Read barcodes from an image.
Overloads of this method accept the input image as System.IO.Stream, as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.String file path types.
Declaration
public static BarcodeResults Read(Stream inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | inputImage | The input image as a System.IO.Stream. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
Read(String, BarcodeReaderOptions)
Read barcodes from an image.
Overloads of this method accept the input image as a System.String file path, as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.IO.Stream types.
Declaration
public static BarcodeResults Read(string inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | inputImage | Filepath to the image. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
ReadAsync(AnyBitmap, BarcodeReaderOptions)
Read barcodes from an image asynchronously.
Declaration
public static Task<BarcodeResults> ReadAsync(AnyBitmap inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| IronSoftware.Drawing.AnyBitmap | inputImage | The input image as an IronSoftware.Drawing.AnyBitmap. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(Byte[], BarcodeReaderOptions)
Reads barcodes from an image.
Binary data of the image as a System.Byte array. JPEG, PNG, BMP, TIFF & GIF image formats are supported.An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior.Declaration
public static Task<BarcodeResults> ReadAsync(byte[] inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | inputImage | |
| BarcodeReaderOptions | barcodeReaderOptions |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(IEnumerable<AnyBitmap>, BarcodeReaderOptions)
Read barcodes from multiple images asynchronously.
Declaration
public static Task<BarcodeResults> ReadAsync(IEnumerable<AnyBitmap> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<IronSoftware.Drawing.AnyBitmap> | inputImages | The input images as an IEnumerable of IronSoftware.Drawing.AnyBitmap. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(IEnumerable<Byte[]>, BarcodeReaderOptions)
Reads barcodes from multiple images asynchronously.
Overloads of this method accept the input images as an IEnumerable of System.Byte arrays, as well as IronSoftware.Drawing.AnyBitmap, string file paths and System.IO.Stream types.
IEnumerable of binary data of the image as a System.Byte array. JPEG, PNG, BMP, TIFF & GIF image formats are supported.An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior.Declaration
public static Task<BarcodeResults> ReadAsync(IEnumerable<byte[]> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Byte[]> | inputImages | |
| BarcodeReaderOptions | barcodeReaderOptions |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(IEnumerable<Stream>, BarcodeReaderOptions)
Reads barcodes from multiple images in parallel. Multiple threads will automatically be started and managed to improve performance for batch barcode reading tasks.
Overloads of this method accept an IEnumerable of System.IO.Stream as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.String file path types.
Declaration
public static Task<BarcodeResults> ReadAsync(IEnumerable<Stream> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.IO.Stream> | inputImages | The input images as an IEnumerable of System.IO.Stream. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(IEnumerable<String>, BarcodeReaderOptions)
Read barcodes from multiple images asynchronously.
Overloads of this method accept the input images as an IEnumerable of System.String file paths as well as IronSoftware.Drawing.AnyBitmap, array of System.Byte and System.IO.Stream types.
Declaration
public static Task<BarcodeResults> ReadAsync(IEnumerable<string> inputImages, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | inputImages | The input images as an IEnumerable of System.String file paths. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(Stream, BarcodeReaderOptions)
Reads barcodes from an image.
Declaration
public static Task<BarcodeResults> ReadAsync(Stream inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | inputImage | The input image as a System.IO.Stream. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadAsync(String, BarcodeReaderOptions)
Read barcodes from an image asynchronously.
Declaration
public static Task<BarcodeResults> ReadAsync(string inputImage, BarcodeReaderOptions barcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | inputImage | The input image file paths. JPEG, PNG, BMP, TIFF & GIF image formats are supported. |
| BarcodeReaderOptions | barcodeReaderOptions | An Options class of BarcodeReader for reading many popular barcode formats from Images and PDFs in expected behavior. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<BarcodeResults> |
ReadPdf(Byte[], PdfBarcodeReaderOptions)
Read barcodes from every page of a PDF document.
Overloads of this method accept the PDF data as an array of System.Byte, as well as System.String path and System.IO.Stream types.
Declaration
public static BarcodeResults ReadPdf(byte[] pdfData, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Byte[] | pdfData | Binary data of the PDF document as a System.Byte array. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from a PDF. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
ReadPdf(Stream, PdfBarcodeReaderOptions)
Read barcodes from every page of a PDF document.
Overloads of this method accept the PDF data as a System.IO.Stream, as well as System.Byte array and System.String file path types.
Declaration
public static BarcodeResults ReadPdf(Stream pdfStream, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.IO.Stream | pdfStream | Binary data of a PDF document as a System.IO.Stream. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from a PDF. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
ReadPdf(String, PdfBarcodeReaderOptions)
Read barcodes from every page of a PDF document.
Overloads of this method accept the PDF data as a System.String file path, as well as System.Byte array and System.IO.Stream types.
Declaration
public static BarcodeResults ReadPdf(string pdfPath, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | pdfPath | System.String file path to a PDF document. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from a PDF. |
Returns
| Type | Description |
|---|---|
| BarcodeResults |
ReadPdfs(IEnumerable<Byte[]>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs.
Overloads of this method accept the PDF data as an IEnumerable of System.Byte arrays, as well as System.String path and System.IO.Stream types.
Declaration
public static List<BarcodeResults> ReadPdfs(IEnumerable<byte[]> pdfData, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Byte[]> | pdfData | An IEnumerable of PDF document binary data as System.Byte arrays. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<BarcodeResults> | A BarcodeResults for each PDF document. |
ReadPdfs(IEnumerable<Stream>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs.
Overloads of this method accept the PDF data as an IEnumerable of System.IO.Stream as well as System.Byte array and System.String file path types.
Declaration
public static List<BarcodeResults> ReadPdfs(IEnumerable<Stream> pdfStreams, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.IO.Stream> | pdfStreams | An IEnumerable of PDF document binary data as a System.IO.Stream. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<BarcodeResults> | A BarcodeResults for each PDF document. |
ReadPdfs(IEnumerable<String>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs.
Overloads of this method accept the PDF data as an IEnumerable of System.String file paths, as well as System.Byte array and System.IO.Stream types.
Declaration
public static List<BarcodeResults> ReadPdfs(IEnumerable<string> pdfPaths, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | pdfPaths | An IEnumerable of System.String file paths to a PDF documents. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<BarcodeResults> | A List of BarcodeResults for each PDF document. |
ReadPdfsAsync(IEnumerable<Byte[]>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs asynchronously.
Overloads of this method accept the PDF data as an IEnumerable of System.Byte arrays, as well as System.String path and System.IO.Stream types.
Declaration
public static Task<List<BarcodeResults>> ReadPdfsAsync(IEnumerable<byte[]> pdfData, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.Byte[]> | pdfData | An IEnumerable of PDF document binary data as System.Byte arrays. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.List<BarcodeResults>> | A BarcodeResults for each PDF document. |
ReadPdfsAsync(IEnumerable<Stream>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs asynchronously.
Overloads of this method accept PDF data as an IEnumerable of System.IO.Stream, as well as System.Byte array and System.String file path types.
Declaration
public static Task<List<BarcodeResults>> ReadPdfsAsync(IEnumerable<Stream> pdfStreams, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.IO.Stream> | pdfStreams | An IEnumerable of PDF document binary data as a System.IO.Stream. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.List<BarcodeResults>> | A BarcodeResults for each PDF document |
ReadPdfsAsync(IEnumerable<String>, PdfBarcodeReaderOptions)
Read barcodes from multiple PDFs asynchronously.
Overloads of this method accept PDF data as an IEnumerable of System.String file paths, as well as System.Byte array and System.IO.Stream types.
Declaration
public static Task<List<BarcodeResults>> ReadPdfsAsync(IEnumerable<string> pdfPaths, PdfBarcodeReaderOptions pdfBarcodeReaderOptions = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Collections.Generic.IEnumerable<System.String> | pdfPaths | An IEnumerable of System.String file paths to PDF documents. |
| PdfBarcodeReaderOptions | pdfBarcodeReaderOptions | An Options class of PdfBarcodeReader for reading barcodes from PDFs. |
Returns
| Type | Description |
|---|---|
| System.Threading.Tasks.Task<System.Collections.Generic.List<BarcodeResults>> | A BarcodeResults for each PDF document |