Overview
ToText() 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
Page selection
Extract only the pages you need:Per-page chunks
UseLlamaMarkdownReader to return one document object per page instead of a single concatenated string. Each chunk includes the page’s plain text and a metadata dictionary with the page number and source file path:
Text property contains the plain Markdown for that page. For plain text specifically, strip Markdown syntax after loading, or call ToText per page using the pages parameter:
Saving to a file
Write the output to a.txt file:
OCR behaviour
LikeToMarkdown(), ToText() can invoke Tesseract OCR on pages that contain no selectable text. Pass useOcr: true to enable it:
For the full API signature, see the ToText() API reference.
Next steps
Extract Markdown
Preserve structure and formatting for LLM pipelines.
Extract JSON
Access bounding boxes and layout data for custom pipelines.
OCR
Control OCR behaviour and language configuration.