LEADTOOLS Barcode toolkits are the most comprehensive barcode toolkits on the market, supporting reading and writing of over 100 different 1D and 2D barcode symbologies (including sub-types):
The barcodes can be read and written from/to any of the hundreds of image file formats supported by LEADTOOLS. For a complete list of image file formats, refer to Summary of All Supported File Formats.
For descriptions and visual samples of the barcode symbologies supported by LEADTOOLS, refer to Supported Barcode Symbologies.
For a chart showing which platforms support the Leadtools.Barcode assembly, refer to Supported Environments. Note that HTML5/JavaScipt supports writing barcodes in the Leadtools.Document assembly.
Includes many broad and functionally specific demo projects with source code for C#, Android, Java, JavaScript, Linux, iOS, macOS, Objective C; as well as many example snippets for common functionality within the documentation.
Full multi-thread support
Broad range of 1D barcode symbols supported, including UPC/EAN, Codabar, GS1 Databar and USPS 4-State
Broad range of 2D barcode symbols supported, including PDF417, MicroPDF417, Datamatrix, QR, MicroQR, Aztec and Maxi
High speed barcode detection and decoding
Find barcodes in the entire image or a specific region of interest
Read an unlimited number of barcodes per page
Detect barcodes at any orientation and rotation angle
Read and write barcodes in both bitonal (black and white) and color images
Barcode data returned with 100% confidence
For more information, refer to:
The LEADTOOLS Barcode support is accessed through the Leadtools.Barcode.dll assembly. The actual barcode read/write code is included in separate assemblies that are loaded dynamically and accessed at runtime. Dynamic loading minimizes the runtime footprint when certain barcode symbologies and features are not needed by your application. The following table lists the .NET Barcode support assemblies and their functionality:
Assembly | Description |
---|---|
Leadtools.Barcode.OneD.dll | 1D Barcodes read/write support |
Leadtools.Barcode.DatamatrixRead.dll | Datamatrix barcodes read support |
Leadtools.Barcode.DatamatrixWrite.dll | Datamatrix barcodes write support |
Leadtools.Barcode.PdfRead.dll | PDF417 and MicroPDF417 barcodes read support |
Leadtools.Barcode.PdfWrite.dll | PDF417 and MicroPDF417 barcodes write support |
Leadtools.Barcode.QrRead.dll | QR barcodes read support |
Leadtools.Barcode.QrWrite.dll | QR barcodes write support |
Leadtools.Barcode.Lead2DRead.dll | Aztec, Maxi and MicroQR barcodes read support |
Leadtools.Barcode.Lead2DWrite.dll | Aztec, Maxi and MicroQR barcodes write support |
For details about Redistributables Paths, Dependencies, NuGet Packages, Sample Programs, and supported Barcode Formats for the .NET, Java/Android, iOS, macOS, JavaScript, Linux, Xamarin, UWP, or Objective C platforms, refer to Getting Started.
Xamarin Framework Deprecation
As of LEADTOOLS v23, the cross-platform Xamarin framework has been deprecated and replaced with LEADTOOLS .NET MAUI framework.
For any LEADTOOLS Xamarin apps you have already built, we recommend you migrate to the LEADTOOLS .NET MAUI framework. To help you with the migration, review the LEADTOOLS .NET MAUI tutorials to get you started.
This change is driven by Microsoft's announcement to end Xamarin support.
For more information, refer to Files to be Included in Your Application.
Refer to the Reading Barcodes and Writing Barcodes tutorials for a step-by-step instruction on how to create a C# barcode application using LEADTOOLS.
The BarcodeEngine class is the main entry to barcode support in Leadtools.Barcode. Simply create a new instance of this class and then obtain a reference to the BarcodeReader object used to read barcode objects though the BarcodeEngine.Reader property or the BarcodeWriter object used to write barcode objects through the BarcodeEngine.Writer property.
To read barcodes, get an instance to the BarcodeReader object stored in the BarcodeEngine.Reader property, then call any of the BarcodeReader.ReadBarcode or BarcodeReader.ReadBarcodes methods passing the RasterImage object containing the image data, an optional search rectangle, optional maximum number of barcodes, optional barcode symbologies (types) and optional extra options. These methods return one or an array of the BarcodeData object containing the barcode data found. Here is an example:
// Read all barcodes in the image
// 1st parameter: theImage is the RasterImage object
// 2nd parameter: A LeadRect.Empty means all images
// 3rd parameter: A 0 means all barcodes found
// 4th parameter: A null array of BarcodeSymbology means all
BarcodeData[] dataArray = barcodeEngineInstance.Reader.ReadBarcodes(
theImage,
LeadRect.Empty,
0,
null);
The BarcodeReader.ReadSymbology event is triggered whenever a barcode is found (or when an error occurs). Subscribe to this event to get information about the barcodes being read and to control whether the whole operation should be aborted or continued in case of an error.
The supported barcode types (symbologies) are defined in the BarcodeSymbology enumeration. The following snippet will search and try to read a single QR barcode from the image:
BarcodeData data = barcodeEngineInstance.Reader.ReadBarcode(
theImage, \\ The RasterImage object
LeadRect.Empty, \\ Search rectangle, Empty means all image
BarcodeSymbology.QR); \\ Symbology, only QR
Fine-tune the barcode reading operation by passing one or more objects derived from BarcodeReadOptions. For example, to change the search direction to both horizontal and vertical barcodes for PDF417, change the default options used by the barcode reader like this:
// Get the default PDF417 read options
PDF417BarcodeReadOptions options = barcodeEngineInstance.Reader.GetDefaultOptions(BarcodeSymbology.PDF417);
// Change the search direction
options.SearchDirection = BarcodeSearchDirection.HorizontalAndVertical;
// Read a PDF417 barcode from the image
BarcodeData data = barcodeEngineInstance.Reader.ReadBarcode(theImage, LeadRect.Empty, BarcodeSymbology.PDF417);
Or alternatively, pass the options directly to this overload method, which only applies these options to this one read operation and not to any subsequent operations:
BarcodeData data = barcodeEngineInstance.Reader.ReadBarcode(theImage, LeadRect.Empty, BarcodeSymbology.PDF417, options);
The BarcodeData object(s) returned from these methods contain the barcode data found. The BarcodeData.Symbology property will contain the symbology (type) of the barcode found; the BarcodeData.GetData method will return the raw byte array of the barcode data read (with BarcodeData.Value as the string representation of the data). The BarcodeData.Bounds and BarcodeData.RotationAngle will contain the location in pixels and any rotation angle of the barcode found on the image.
When reading some barcode types, extra information may be stored in the barcode other than the data, such as the symbol size of a Datamatrix barcode or the group number of a PDF417 barcode. For these, LEADTOOLS defines derived classes from BarcodeData (DatamatrixBarcodeData and PDF417BarcodeData in the cases mentioned) that contains this extra data. Check if the symbology is of the correct type and then cast the returned BarcodeData object to the derived class type.
To write a barcode to an image, get an instance to the BarcodeWriter object stored in the BarcodeEngine.Writer property. Then, call BarcodeWriter.WriterBarcode passing the RasterImage object that contains the image data to write the barcode, and a BarcodeData object that contains the data and bounds of the desired barcode. Here is an example:
// Create a UPC A barcode
BarcodeData data = new BarcodeData();
data.Symbology = BarcodeSymbology.UPCA;
data.Value = "01234567890";
data.Bounds = new LeadRect(10, 10, 600, 200);
// Write it with default options
barcodeEngineInstance.Writer.WriteBarcode(theImage, data, null);
Use one or more of the BarcodeWriteOptions-derived classes to add extra functionality to the write operation. For example, the following code will cause all subsequent write operations to show the barcode text on the bottom when 1D barcodes are written:
OneDBarcodeWriteOptions options = barcodeEngineInstance.Writer.GetDefaultOptions(BarcodeSymbology.UPCA) as OneDBarcodeWriteOptions;
options.TextPosition = OneDBarcodeTextPosition.Default;
// Write it with default options
barcodeEngineInstance.Writer.WriteBarcode(theImage, data, null);
Or you can write just this barcode with these options using this:
barcodeEngineInstance.Writer.WriteBarcode(theImage, data, options);
When writing barcodes, you may want to calculate the barcode size in pixels and fine tune the options before committing (for example, change the XModule spacing). Use the BarcodeWriter.CalculateBarcodeDataBounds method to fill the BarcodeData.Bounds property with the size in pixels of the requested barcode with the requested options.
LEADTOOLS supports the reading and writing of several major types of barcodes. These types include:
Linear barcodes (1D)
PDF417 (2D)
MicroPDF417 (2D)
Datamatrix (2D)
QR (2D)
MicroQR (2D)
Aztec (2D)
Maxi (2D)
The individual supported symbologies are defined by the BarcodeSymbology enumeration.
For each major type of barcode, one or more subtypes are supported for both reading and writing. These subtypes are:
EAN 13
EAN 8
UPC A
UPC E
Code 3 of 9
Code 128
Code 93
Interleaved 2 of 5
CODABAR
UCCEAN 128
EAN EXT 5
EAN EXT 2
MSI
Code 11
Standard 2 Of 5
GS1 Databar (formerly RSS14) Omnidirectional
GS1 Databar (formerly RSS14) Truncated
GS1 Databar (formerly RSS14) Limited
GS1 Databar (formerly RSS14) Expanded
Patch Code
Postnet
Planet
Australian Post - 4 State
Royal Mail (RM4SCC)
GS1 Databar (formerly RSS14) Stacked
GS1 Databar (formerly RSS14) Stacked Omnidirectional
GS1 Databar (formerly RSS14) Expanded Stacked
PDF417
MicroPDF417
Datamatrix (with multiple symbol sizes)
QR (with multiple symbol models)
MicroQR (with multiple symbol models)
Aztec (with multiple symbol models)
Maxi (with multiple symbol models)
For descriptions and visual samples of the barcode symbologies supported by LEADTOOLS, refer to Supported Barcode Symbologies.
Code 128 Barcodes in LEADTOOLS
Datamatrix Barcodes in LEADTOOLS
GS1 Databar / RSS-14 Barcodes in LEADTOOLS
MicroPDF417 Barcodes in LEADTOOLS
Miscellaneous Barcodes in LEADTOOLS
MSI Barcodes (Pulse Width Modulated) in LEADTOOLS
PDF417 and MicroPDF417 Barcodes in LEADTOOLS
UPC / EAN Barcodes in LEADTOOLS