Scan Barcode

GroupDocs.Parser .Net allows to scan barcode from PDF, Microsoft Office formats: Word (DOC, DOCX), PowerPoint (PPT, PPTX), LibreOffice formats and many others (see full list at supported document formats article).

GroupDocs.Parser’s barcode scanner is easy to use and powerful at the same time. Our experience allowed us to implement sophisticated algorithms, which allows to read even damaged barcodes.

This article demonstrates how to implement the simplest scenario - read barcode from any supported format without additional settings (to resolve complex scenarios see advanced usage section.

How to scan barcode in .Net with GroupDocs.Parser

To scan barcode from your file, simply call GetBarcodes method:

IEnumerable<PageBarcodeArea> GetBarcodes();

This method returns a collection of PageBarcodeArea objects.

Here are the steps to extract a barcode from file:

  • Instantiate Parser object for the initial file;
  • Check if the file supports barcodes extraction;
  • Call GetBarcodes method and obtain collection of PageBarcodeArea objects;
  • Iterate through the collection and get a barcode value.

The following example shows how to scan barcode:

// Create an instance of Parser class
using (Parser parser = new Parser(Constants.SamplePdfWithBarcodes))
    // Check if the file supports barcodes extraction
    if (!parser.Features.Barcodes)
        Console.WriteLine("The file doesn't support barcodes extraction.");

    // Scan barcodes from the file.
    IEnumerable<PageBarcodeArea> barcodes = parser.GetBarcodes();

    // Iterate over barcodes
    foreach (PageBarcodeArea barcode in barcodes)
        // Print the page index
        Console.WriteLine("Page: " + barcode.Page.Index.ToString());
        // Print the barcode value
        Console.WriteLine("Value: " + barcode.Value);

More resources

Advanced usage topics

To learn more about scan barcode features, please refer the advanced usage section.

GitHub examples

You may easily run the code above and see the feature in action in our GitHub examples:

Free online Barcode Scanner App

Along with full featured .NET library we provide simple, but powerful free Apps.

You are welcome to scan barcode from your files or mobile phone camera with our free online GroupDocs Scanner App which is build with GroupDocs.Parser .Net.

© Aspose Pty Ltd 2001-2022. All Rights Reserved.