Read Barcodes

Reading barcodes using IronBarCode is effective and simple. IronBarcode supports various formats and has different methods for each situation. Whether you are a developer looking to read barcodes from images or a developer who needs to integrate a barcode application and manipulate the data, IronBarcode has you covered.

Barcode Reader in C#

Below are some examples of how you can use the IronBarcode library to read barcodes from different sources using C#:

// Reading a barcode from a PNG file
var resultFromFile = BarcodeReader.Read(@"file/barcode.png");

// Reading a barcode from a Bitmap image
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp"));

// Reading a barcode from an Image object created from a JPEG file
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg"));

// Reading a barcode from a Stream
var resultFromStream = BarcodeReader.Read(myStream);

// Reading barcodes from a PDF document
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf");
// Reading a barcode from a PNG file
var resultFromFile = BarcodeReader.Read(@"file/barcode.png");

// Reading a barcode from a Bitmap image
var resultFromBitMap = BarcodeReader.Read(new Bitmap("barcode.bmp"));

// Reading a barcode from an Image object created from a JPEG file
var resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg"));

// Reading a barcode from a Stream
var resultFromStream = BarcodeReader.Read(myStream);

// Reading barcodes from a PDF document
var resultFromPdf = BarcodeReader.ReadPdf(@"file/mydocument.pdf");
' Reading a barcode from a PNG file
Dim resultFromFile = BarcodeReader.Read("file/barcode.png")

' Reading a barcode from a Bitmap image
Dim resultFromBitMap = BarcodeReader.Read(New Bitmap("barcode.bmp"))

' Reading a barcode from an Image object created from a JPEG file
Dim resultFromImage = BarcodeReader.Read(Image.FromFile("barcode.jpg"))

' Reading a barcode from a Stream
Dim resultFromStream = BarcodeReader.Read(myStream)

' Reading barcodes from a PDF document
Dim resultFromPdf = BarcodeReader.ReadPdf("file/mydocument.pdf")
$vbLabelText   $csharpLabel

With the BarcodeReader.Read method, developers can pass along the file path of any standard image formats such as png, jpg, and jpeg to quickly read the values within the file. Furthermore, the BarcodeReader.Read method works for Bitmap and AnyBitmap. This is ideal for applications that require manipulating or passing values using the standard Bitmap class. For developers needing a universally compatible Bitmap format across .NET 7, .NET 6, .NET 5, and .NET Core, the AnyBitmap class offers a platform-agnostic solution. It enables seamless cross-compatibility, allowing you to write flexible code and pass variables without any obstructions.

The BarcodeReader class also has specific methods for reading barcodes from a PDF using ReadPdf to read barcodes from every image embedded in the PDF document, allowing developers to quickly obtain all barcodes.

Aside from the specified methods, the BarcodeReader methods allow developers to pass in the BarcodeReaderOptions for more fine-grain control and customization. This applies to every method within the BarcodeReader class, enabling options such as reading only the first barcode to save time, reading specific types of barcodes, and utilizing multithreading, among other customization options.

Click here to view the How-to Guide, including examples, sample code, and files