Class BarcodeReader
- Namespace
- LMKit.Extraction.Barcodes
- Assembly
- LM-Kit.NET.dll
Finds and decodes the barcodes of an image or of document pages: 1D codes (Code 128, Code 39, EAN/UPC, ITF, DataBar...), 2D codes (QR, Data Matrix, PDF417, Aztec, MaxiCode) and their variants.
public sealed class BarcodeReader
- Inheritance
-
BarcodeReader
- Inherited Members
Examples
Example: read every barcode of a scanned batch
using LMKit.Extraction.Barcodes;
var reader = new BarcodeReader();
foreach (BarcodePage page in reader.ReadPages("batch.pdf"))
{
foreach (BarcodeDetection barcode in page.Barcodes)
{
Console.WriteLine($"Page {page.PageNumber}: {barcode.FormatName} {barcode.Text}");
}
}
Remarks
Deterministic image analysis by the ZXing-C++ reader compiled into the LM-Kit.ocr native library: no model is loaded and no AI feature is involved.
A PDF (or any renderable document) page is rendered at the requested resolution; an image page is read at its own resolution. An instance holds options only: it is reusable, and safe to use from several threads.
Constructors
- BarcodeReader()
Initializes a reader with the default options.
- BarcodeReader(BarcodeReaderOptions)
Initializes a reader with the specified options.
Fields
- DefaultDpi
The resolution document pages are rendered at by default, in DPI.
Properties
- NativeVersion
Gets the version of the native barcode reader ("3.1.1").
- Options
Gets the options the reader searches with.
Methods
- Read(Attachment, int, int, CancellationToken)
Reads every barcode of one page of a document (PDF, image, multi-page TIFF...).
- Read(ImageBuffer, CancellationToken)
Reads every barcode of a decoded image, in the order the reader found them. An image without a barcode returns an empty list.
- Read(string, CancellationToken)
Reads every barcode of an image file (its first page for a multi-page TIFF).
- ReadAsync(Attachment, int, int, CancellationToken)
Reads every barcode of one page of a document (PDF, image, multi-page TIFF...).
- ReadAsync(ImageBuffer, CancellationToken)
Reads every barcode of a decoded image, in the order the reader found them. An image without a barcode returns an empty list.
- ReadAsync(string, CancellationToken)
Reads every barcode of an image file (its first page for a multi-page TIFF).
- ReadPages(Attachment, string, int, CancellationToken)
Reads every barcode of the pages of a document (PDF, image, multi-page TIFF...). Pages are decoded in parallel; a page that cannot be read is returned with its Error instead of stopping the others.
- ReadPages(byte[], string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document held in memory.
- ReadPages(Stream, string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document read from a stream (left open).
- ReadPages(string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document file.
- ReadPagesAsync(Attachment, string, int, CancellationToken)
Reads every barcode of the pages of a document (PDF, image, multi-page TIFF...). Pages are decoded in parallel; a page that cannot be read is returned with its Error instead of stopping the others.
- ReadPagesAsync(byte[], string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document held in memory.
- ReadPagesAsync(Stream, string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document read from a stream (left open).
- ReadPagesAsync(string, string, int, string, CancellationToken)
Reads every barcode of the pages of a document file.