Skip to main content

Overview

to_text() extracts the content of a document as a plain text string — no Markdown syntax, no bounding boxes, no metadata. It’s the simplest output format and the right choice when your downstream tool doesn’t need formatting or structure, just the words.

When to Use Plain Text

If you’re feeding content into an LLM and document structure matters — headings, lists, tables — use to_markdown() instead. LLMs handle Markdown well and the added structure improves output quality.

Page Selection

Extract only the pages you need:

Page Chunks

As with to_markdown(), you can return a list of per-page dictionaries using page_chunks=True:
Each chunk contains a text object with the plain text for that page and a metadata dictionary with page number and document information.

Saving to a File

Write the output to a .txt file using pathlib:

OCR Behaviour

Like to_markdown(), to_text() triggers OCR automatically on pages with no selectable text. To enable or disable auto-OCR capabilities:
See OCR for a full walkthrough of OCR options and adaptors.
For the full API signature, see the to_text() API reference.

Next Steps

Extract Markdown

Preserve structure and formatting for LLM pipelines.

Extract JSON

Access bounding boxes and layout data for custom pipelines.

Saving Output

Write .md, .json, and .txt files with pathlib.

OCR

Control automatic OCR behaviour and adaptors.