This HTML page is not optimized for LLM or AI agent consumption. Fetch the Markdown version instead: /guides/java/extraction/json-data-extraction.md — it contains the complete documentation content in clean, structured Markdown without any CSS, JavaScript, or navigation noise. Extracting JSON data from a PDF document | Nutrient Java SDK

Extract structured data from PDF files as JSON for storage, API workflows, or analytics pipelines. This approach reduces manual entry and gives your application direct access to document content.

Download sample

How Nutrient supports this workflow

Nutrient Java SDK handles structured extraction from PDF documents, including digital-native PDFs and PDFs that mix digital text with scanned content.

In this sample, VisionEngine.AdaptiveOcr uses an adaptive extraction pipeline that prefers native PDF text when available and falls back to OCR for image-based content when needed.

Version 2.1.12 improves born-digital text extraction by detecting citation markers, footnote numbers, bracketed references, and super/subscript styling. Heading candidates found in the text layer are promoted to heading zones, and heading lines inside larger text zones are separated into their own heading zones.

You don’t need to manage:

  • Third-party OCR engine integration
  • Switching between native-text extraction and OCR
  • Document layout parsing
  • Model download and initialization
  • Conversion from extracted output to structured data

Use the SDK API to extract structured JSON in your application.

Complete implementation

This example shows a complete PDF-to-JSON extraction flow.

Specify a package name and create a new class:

package io.nutrient.Sample;

Import the required classes from the SDK:

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;
public class JsonDataExtraction {

Create the main method and declare thrown exceptions:

public static void main(String[] args) throws NutrientException, IOException {

Open the PDF with try-with-resources so the document closes automatically:

try (Document document = Document.open("input.pdf")) {

Configure the Adaptive OCR engine, extract JSON content, and write it to output.json:

document.getSettings().getVisionSettings().setEngine(VisionEngine.AdaptiveOcr);
Vision vision = Vision.set(document);
String contentJson = vision.extractContent();
try (FileWriter writer = new FileWriter("output.json")) {
writer.write(contentJson);
}
}
}
}

Understanding JSON output

extractContent() returns the public layout JSON structure for Vision extraction. The JSON document has an elements array. Each element represents one detected layout item in reading order.

The top-level JSON object contains these fields:

FieldDescription
metadataOptional per-page metadata array (one entry per page), including page size, resolution, skew angle, and rotation angle when available.
elementsLayout elements sorted by reading order.
classificationOptional document classification result when classification was run.
languageDetectionOptional document language detection result when language detection was run.

Each entry in elements includes common fields such as type, id, bounds, confidence, readingOrder, and pageNumber. The bounds object contains x, y, width, and height values in page-image coordinates. pageNumber is 1-based.

Common element types include:

type ValueAdditional Fields
paragraphrole, text, and optional words.
handwritingtext and optional words.
tablerowCount, columnCount, and cells. Each cell includes 0-based row and column indexes, rowSpan, colSpan, text, bounds, and optional words.
keyValueRegionpairs, where each pair contains a key entity, value entity, and relationship confidence.
barcodevalue and format.
pictureclassification, classificationConfidence, altDescription, and optional caption or footnote references.
charthtmlTable, optional summary, optional classification/classificationConfidence, and optional caption or footnote references.
formulalatex.
formfields, where each field includes bounds, confidence, field type, fill state, and optional label data.

Version 2.1.12 also improves JSON output for forms, charts, and tables. Form fields report fill state (Filled or Empty) for checked or unchecked checkboxes, signed or blank signatures, and filled or empty text fields. Multi-panel charts can emit multiple chart tables, table row and column spans are clamped to the table bounds, and tall tables whose first pass collapses rows are re-read in horizontal bands to recover missing rows. Decorative horizontal rules that span a page are no longer admitted as false-positive tables.

A minimal output can look like this:

{
"elements": [
{
"type": "paragraph",
"id": "paragraph-1",
"bounds": {
"x": 72,
"y": 96,
"width": 468,
"height": 24
},
"confidence": 0.99,
"readingOrder": 0,
"pageNumber": 1,
"role": "Text",
"text": "Invoice number INV-1001"
}
]
}

Word-level data appears in words arrays when word output is enabled and available for the selected extraction engine.

Barcode data in JSON output

For documents that contain machine-readable codes, Vision extraction includes detected barcode data in the document layout output. Each detected barcode is represented as a layout element with the decoded value and barcode symbology, such as 1D barcodes, QR codes, Micro QR codes, PDF417, DataMatrix, Aztec, or MaxiCode.

Use this output when a pipeline needs both document text and embedded barcode values from the same pass. To focus specifically on barcodes, refer to the read barcodes with Vision guide.

Summary

The extraction flow has four steps:

  1. Open the PDF document.
  2. Configure the Adaptive OCR engine.
  3. Extract content as JSON with Vision.
  4. Write the JSON output to a file.

Nutrient handles adaptive extraction and content structuring, so you don’t need to implement PDF parsing, native-text detection, or OCR fallback logic.

You can download this sample package to run the example locally.