---
title: "Reading barcodes with vision extraction | Nutrient Java SDK"
canonical_url: "https://www.nutrient.io/guides/java/extraction/read-barcodes-with-vision/"
md_url: "https://www.nutrient.io/guides/java/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 Java 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/java/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

Specify a package name and import the classes used by the sample:

```java

package io.nutrient.Sample;

import io.nutrient.sdk.Document;
import io.nutrient.sdk.Vision;
import io.nutrient.sdk.enums.VisionEngine;
import io.nutrient.sdk.exceptions.NutrientException;

import java.io.FileWriter;
import java.io.IOException;

```

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

```java

public class ReadBarcodesWithVision {
    public static void main(String[] args) throws NutrientException, IOException {
        try (Document document = Document.open("input_barcode_1d.png")) {
            document.getSettings().getVisionSettings().setEngine(VisionEngine.Icr);

            Vision vision = Vision.set(document);
            String contentJson = vision.extractContent();

            try (FileWriter writer = new FileWriter("output.json")) {
                writer.write(contentJson);
            }

            System.out.println("Successfully extracted document layout and barcode data to output.json");
        }
    }
}

```

`extractContent()` 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/java/extraction/json-data-extraction.md) guide.

## Error handling

Vision API throws `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

- [Applying OCR to a PDF document](/guides/java/extraction/apply-ocr-to-pdf.md)
- [Applying OCR to a PDF page](/guides/java/extraction/apply-ocr-to-pdf-page.md)
- [Classifying documents](/guides/java/extraction/classify-document.md)
- [Generating image descriptions using local AI](/guides/java/extraction/describe-image-with-local-ai.md)
- [Generating image descriptions using OpenAI](/guides/java/extraction/describe-image-with-openai.md)
- [Generating image descriptions using Claude](/guides/java/extraction/describe-image-with-claude.md)
- [Detecting document language](/guides/java/extraction/detect-document-language.md)
- [Extracting data from images using ICR](/guides/java/extraction/extract-data-from-image-icr.md)
- [Extracting data from images using OCR](/guides/java/extraction/extract-data-from-image-ocr.md)
- [Extracting data from specific pages](/guides/java/extraction/extract-data-from-specific-pages.md)
- [Extracting data from images using vision language models](/guides/java/extraction/extract-data-from-image-vlm.md)
- [Extracting form fields from images](/guides/java/extraction/extract-form-fields-from-image.md)
- [Extracting structured data from documents](/guides/java/extraction/extract-structured-data.md)
- [Generating extraction schemas](/guides/java/extraction/generate-extraction-schema.md)
- [Nutrient Java SDK extraction guides](/guides/java/extraction.md)
- [Extracting JSON data from a PDF document](/guides/java/extraction/json-data-extraction.md)
- [Extracting text from PDF documents](/guides/java/extraction/pdf-to-text.md)
- [Labeling form fields with a vision language model](/guides/java/extraction/label-form-fields-with-vlm.md)
- [Extracting text from images](/guides/java/extraction/read-text-from-image.md)
- [Speeding up first ICR operation by predownloading models](/guides/java/extraction/speed-up-first-icr-by-downloading-requirements.md)
- [Searching document text](/guides/java/extraction/search-document-text.md)
- [Extracting text from multilingual images](/guides/java/extraction/read-text-from-image-multi-language.md)

