Document to Text
Extract plain text from PDF, Word, OpenDocument, RTF, and plain text files. Single file or batch directory mode. No LibreOffice required.
Why this exists
Most document-analysis jobs (resume screening, contract review, expense extraction) need the text content of a file — not its visual rendering. Going through PDF is expensive: it requires LibreOffice (~700 MB) for .doc/.docx/.odt conversion, and the AI still has to re-extract text from the rendered PDF.
This tool extracts text directly from the source, with zero install
friction for modern formats (.txt, .docx, .odt — pure stdlib).
PDF and RTF need small pip packages; the script prints a clear install
command if a backend is missing.
For workflows that need rendered-PDF fidelity (form-field positions, images, page-perfect layout), use a doc-to-pdf converter instead.
Inputs
| Property | Required | Default | Description |
|---|---|---|---|
inputFile |
one of two | — | Path to a single document. |
inputDir |
one of two | — | Folder whose matching files are all processed. |
extensions |
— | pdf,docx,odt,rtf,txt |
Comma-separated extensions when using inputDir. |
outputFile |
— | — | If set, all extracted text is concatenated and written here with per-file headers. |
outputDir |
— | — | If set, writes one .txt per input document. |
maxBytes |
— | 0 |
Per-file byte cap (0 = unlimited). |
Provide either inputFile or inputDir, not both.
Outputs (published)
| Name | Description |
|---|---|
text |
Full concatenated text with per-file headers. |
fileCount |
How many input files matched. |
successCount |
How many extracted cleanly. |
failureCount |
How many errored. |
outputFiles |
Comma-separated list of files this task wrote. |
errors |
Newline-separated error messages, one per failed file. |
Format support
| Extension | Backend | Install required? |
|---|---|---|
.txt |
stdlib (utf-8, utf-16, latin-1 fallback) | None |
.docx |
stdlib (zipfile + xml.etree) |
None |
.odt |
stdlib (zipfile + xml.etree) |
None |
.rtf |
striprtf (pip) — regex fallback if missing |
pip install striprtf (optional) |
.pdf |
pypdf or pdfminer.six |
pip install pypdf |
.doc |
antiword or catdoc binary |
apt install antiword catdoc (or brew install antiword) |
The legacy binary .doc format is rare in practice — most modern Word
files are .docx. If you only have .doc originals, install antiword
or catdoc (the script tries both), or save them as .docx first.
Installing the pip packages on Debian/Ubuntu/Mint (PEP 668)
Modern Debian-based distros mark the system Python as
"externally managed" and refuse pip install without an extra flag.
Three options, in order of cleanliness:
- Use the runtime env's Python directly (recommended for InTouch):
pip install --user --break-system-packages pypdf striprtf - Set up a virtualenv and point your
pythonruntime env at it (no global state changes). - Skip PDFs/RTFs — the
.docx/.odt/.txtpaths work with zero dependencies. The tool still succeeds on those and reports per-file errors for the formats whose backend is missing.
Chaining patterns
- Resume folder → Claude assessment —
document-to-texton/path/to/resumes→ publishestext→ feed toanthropictask as{{document-to-text.text}}in the prompt. - Invoice email attachments → SQL — pull attachments, run them
through
document-to-text, then parse andINSERT. - Knowledge-base ingest → embeddings — extract text from a doc
folder, chunk with
document_chunker, embed withembeddings.
Example
name: resume-review
tasks:
- name: extract
tool: document-to-text
properties:
inputDir: /home/me/resumes
maxBytes: "100000"
- name: assess
tool: anthropic
credential: claude-api
properties:
prompt: |
Assess the following resumes. For each candidate, extract skills,
experience level, and a 1-10 rating.
{{extract.text}}
maxTokens: 4000
outputFile: /home/me/resume-assessment.txt