---
name: "pdf-structure-extraction"
description: "Extract page-linked text from a text PDF and identify pages that need OCR. Use when the user needs: Get JSON with page numbers, extracted text and explicit OCR-needed flags."
license: "MIT"
metadata: {"version": "2026-10-17.1", "category": "data-parsing", "publisher": "AIDiveForge"}
---

# PDF Structure Extraction

Get JSON with page numbers, extracted text and explicit OCR-needed flags.

## Requirements

Python 3.10+ and pypdf are required for the included extraction helper.

## Workflow

1. Run scripts/extract_pdf.py input.pdf --output extracted.json in a Python environment with pypdf installed.
2. Inspect pages[].text alongside the original PDF. Keep page_number on every passage you reuse.
3. If a page is flagged needs_ocr, report that limitation; this helper does not install or run OCR.
4. Group passages into sections only where headings are visible in the source. Keep uncertain layout and reading order explicit.
5. For a table, compare row and column boundaries with the page image before treating extracted text as cells.

## Worked example

Read `examples/input.txt` and `examples/expected.txt` before adapting the workflow.

## Acceptance checks

Both fixture pages retain their numbers and expected text; a blank/scanned page is flagged rather than silently reported as extracted.

## Limits

Text extraction cannot recover arbitrary table semantics or scanned text. Layout and OCR are separate checks; no 90% accuracy claim is made.

Worked example included. Model-specific performance and vendor compatibility have not been benchmarked.
