---
title: "Reading barcodes with vision extraction | Nutrient Python SDK"
canonical_url: "https://www.nutrient.io/guides/python/extraction/read-barcodes-with-vision/"
md_url: "https://www.nutrient.io/guides/python/extraction/read-barcodes-with-vision.md"
last_updated: "2026-07-10T00:00:00.000Z"
description: "Read barcodes as part of document layout analysis using Nutrient Python SDK."
---

# Reading barcodes with vision extraction

Use Vision extraction to read barcodes as part of document layout analysis. This workflow extracts text, tables, reading order, and machine-readable codes in one pass.

Use this guide when a document processing pipeline needs barcode values together with surrounding document context, such as page location or nearby text.

[Download sample](https://www.nutrient.io/downloads/samples/python/read-barcodes-with-vision.zip)

## Supported barcode types

Vision barcode recognition supports common 1D and 2D symbologies, including:

- Code 128, Code 39, EAN, UPC, and other 1D formats

- QR codes and Micro QR codes

- PDF417

- DataMatrix

- Aztec

- MaxiCode

Recognition quality depends on image resolution, barcode size, contrast, rotation, and damage. Use a direct barcode reader for workflows that only need barcode values from a single image.

## Complete implementation

Import the classes used by the sample:

```python

from nutrient_sdk import Document
from nutrient_sdk import NutrientException
from nutrient_sdk import Vision
from nutrient_sdk import VisionEngine

```

Open the document, select the ICR engine, and extract the document layout as JSON:

```python

def main():
    try:
        with Document.open("input_barcode_1d.png") as document:
            document.settings.vision_settings.engine = VisionEngine.ICR

            vision = Vision.set(document)
            content_json = vision.extract_content()

            with open("output.json", "w", encoding="utf-8") as f:
                f.write(content_json)

            print("Successfully extracted document layout and barcode data to output.json")
    except NutrientException as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()

```

`extract_content()` returns JSON that includes detected barcode elements when the input contains supported barcodes. Each barcode element contains the decoded value and symbology information, together with its location in the document layout.

## Markdown output

Markdown export surfaces barcode values as text in reading order. It doesn't preserve the full coordinate data available in JSON.

Use JSON when downstream code needs page numbers, bounding boxes, decoded values, or symbology metadata. For the full layout JSON structure, refer to the [JSON data extraction](https://www.nutrient.io/guides/python/extraction/json-data-extraction.md) guide.

## Error handling

Vision API raises `VisionException` when extraction fails. `VisionException` derives from `NutrientException`, so catching `NutrientException` covers Vision-specific failures. Common causes include unreadable input files, unsupported image data, missing Vision resources, insufficient memory, or low-quality barcode images.

In production code:

- Catch `NutrientException`.

- Log the input file and Vision engine used for extraction.

- Route low-quality scans to manual review or retry with a higher-resolution source image.

## Summary

This workflow extracts barcode values through the Vision document layout pipeline. Use it when barcode values need to remain connected to the document structure, page location, and surrounding text.
---

## Related pages

- [Nutrient Python SDK extraction guides](/guides/python/extraction.md)
- [Applying OCR to a PDF page](/guides/python/extraction/apply-ocr-to-pdf-page.md)
- [Applying OCR to a PDF document](/guides/python/extraction/apply-ocr-to-pdf.md)
- [Classifying documents](/guides/python/extraction/classify-document.md)
- [Generating image descriptions using Claude](/guides/python/extraction/describe-image-with-claude.md)
- [Generating image descriptions using local AI](/guides/python/extraction/describe-image-with-local-ai.md)
- [Generating image descriptions using OpenAI](/guides/python/extraction/describe-image-with-openai.md)
- [Detecting document language](/guides/python/extraction/detect-document-language.md)
- [Extracting data from images using ICR](/guides/python/extraction/extract-data-from-image-icr.md)
- [Extracting data from images using OCR](/guides/python/extraction/extract-data-from-image-ocr.md)
- [Extracting data from images using vision language models](/guides/python/extraction/extract-data-from-image-vlm.md)
- [Extracting data from specific PDF pages](/guides/python/extraction/extract-data-from-specific-pages.md)
- [Extracting form fields from images](/guides/python/extraction/extract-form-fields-from-image.md)
- [Extracting structured data from documents](/guides/python/extraction/extract-structured-data.md)
- [Generating extraction schemas](/guides/python/extraction/generate-extraction-schema.md)
- [Extracting structured JSON data from PDF documents](/guides/python/extraction/json-data-extraction.md)
- [Labeling form fields with a vision language model](/guides/python/extraction/label-form-fields-with-vlm.md)
- [Opening password-protected PDFs](/guides/python/extraction/open-password-protected-pdf.md)
- [Extracting text from PDF documents](/guides/python/extraction/pdf-to-text.md)
- [Extracting text from multilingual images](/guides/python/extraction/read-text-from-image-multi-language.md)
- [Extracting text from images](/guides/python/extraction/read-text-from-image.md)
- [Later, in another process — no document needed:](/guides/python/extraction/search-document-text.md)
- [Speeding up first ICR operation by predownloading models](/guides/python/extraction/speed-up-first-icr-by-downloading-requirements.md)
- [Split documents](/guides/python/extraction/split-document.md)

