# Documents, S3, images and OCR

Load and parse PDFs, Office files, EPUB, HTML, CSV, JSON and more; read from S3-compatible storage; and extract text from images and scanned PDFs with local OCR.

Source: https://glamorous-boar.cloudvent.net/documents-and-files/

---

## Supported formats

The **Document Loader** (and the S3 Loader, which shares its parsers) turns files into `Document` values:

| Format | How it is parsed |
|---|---|
| **PDF** | One document per page by default (`split_pdf_pages`), enabling page citations. `pdf_layout` rebuilds lines from text runs and turns lines 15 %+ larger than the body font into Markdown headings. Pages without a text layer are OCR'd (`ocr: auto`). |
| **DOCX** | Headings become Markdown headings; tables become Markdown table rows. |
| **XLSX** | One part per sheet (or per row with `csv_mode: rows`); first row is the header; formulas give their cached value. |
| **PPTX** | One part per slide in order, including speaker notes. |
| **EPUB** | One part per chapter in spine order. |
| **HTML** | Lists become `- ` items, tables become rows, `<pre>` becomes fenced code. |
| **Markdown, TXT, RST, LOG** | As text. |
| **CSV / TSV** | Whole file, or one document per row (`csv_mode: rows`). |
| **JSON / JSONL / NDJSON** | JSONL per record. |
| **XML, YAML** | As text. |
| **Images** (PNG, JPEG, WebP, GIF, BMP, TIFF) | OCR. |

Not supported: legacy `.doc`, `.xls`, `.ppt`; SVG uploads (they can carry scripts). Spreadsheet dates appear as serial numbers. Archive formats are protected against zip bombs (at most 5,000 entries, 64 MB per entry and 256 MB per file uncompressed, measured on bytes actually read).

## Documents

Each document has a deterministic ID (`<artifact>:p<page>#c<chunk>`), `content`, `source` (`uri`, `filename`, `media_type`, `artifact_id`, `page`, `section`), `metadata`, optional `parent_id`, exact character `offsets` in its parent and an `ingestion_version` recording which nodes produced it. Stable IDs keep citations and evaluation datasets valid across runs.

**Document Cleaner** then normalises text (NFKC Unicode, control characters, words hyphenated across lines, whitespace runs) and drops empty or too-short documents.

## S3 and S3-compatible storage

**S3 Loader** reads from Amazon S3, MinIO, Cloudflare R2, Wasabi, Backblaze B2 and other S3-compatible services.

1. Set `bucket`, and either `prefix` (with `include` patterns like `*.pdf, *.md`) or explicit `keys`.
2. Choose `auth`:
   - `keys`: `access_key_id` and `secret_access_key` secrets (optional `session_token`);
   - `environment`: the API server's own AWS identity (env vars, `~/.aws`, instance or task role);
   - `anonymous`: public buckets.
3. For S3-compatible storage set `endpoint_url` (MinIO `http://localhost:9000`, R2 `https://<account>.r2.cloudflarestorage.com`) and `region` (R2: `auto`).
4. Limits: `max_files` (50) and `max_file_mb` (50).

Documents carry `s3://bucket/key`, ETag and last-modified. Endpoints that resolve to link-local or cloud-metadata addresses are refused, so the server's own cloud credentials cannot be fetched through a crafted endpoint (SSRF protection).

## OCR (local, open source)

AgenticMind uses **RapidOCR** (PaddleOCR models on ONNX Runtime, Apache-2.0), running locally on the CPU.

- **Inside the Document Loader**: `ocr: auto` (default) OCRs image files and PDF pages without a text layer. Text PDFs never run OCR. `ocr_min_confidence` (0.5) drops uncertain lines.
- **OCR node**: reads `image`/`images` inputs or selected `files` (images or scanned PDFs) and outputs `text` plus one document per image or page, with OCR metadata (engine, lines, confidence). Lines are kept in reading order.
- Models load on first use; for offline machines pre-fetch them with `rapidocr download_models`.
- Default models cover English and Chinese. No handwriting models.

## Images for vision models

- **Image Input**: an image given at run time (Run inputs picker or Chat attach button).
- **Image Loader**: images selected from project files (`image` = first, `images` = list).

Connect either to an LLM's `image`/`images` inputs. See [Models and providers](/models-and-providers/#vision).

## Limits

- 50 MB per upload by default (`AGENTICMIND_MAX_UPLOAD_MB`).
- No table extraction from PDFs; multi-column PDFs keep the content-stream order.
- No image resizing: downscale very large photos before upload.
