Extract barcodes from document

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Parser MCP server lets your agent work with files on your machine; they are never uploaded. It runs in Docker: replace /path/to/documents with the folder it may use.

claude mcp add groupdocs-parser -- docker run --rm -i -v /path/to/documents:/data ghcr.io/groupdocs-parser/parser-net-mcp:latest
Folders, licensing and more →

GroupDocs.Parser provides the functionality to extract barcodes from documents by the GetBarcodes method:

IEnumerable<PageBarcodeArea> GetBarcodes();

This method returns a collection of PageBarcodeArea objects:

MemberDescription
PageThe page that contains the text area.
RectangleThe rectangular area on the page that contains the text area.
ValueA string value that represents a value of the barcode page area.
CodeTypeNameA string value than represents a type name of the barcode.
ConfidenceThe level of confidence of the parsered barcode.
AngleThe angle of the barcode.

Here are the steps to extract all barcodes from the whole document:

  • Instantiate Parser object for the initial document;
  • Check if the document 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 extract barcodes from a document:

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

    // Extract barcodes from the document.
    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

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 powerfull 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.