Extract plain text from PDF
extract_textExtract plain text from non-encrypted PDFs by processing each page's content stream. Indicates whether extraction succeeded and why if it failed.
Instructions
Best-effort plain-text extraction from a non-encrypted PDF. Walks each page's content stream and pulls the operands of Tj/'/"/TJ text operators. The result.extractable boolean is FALSE when one or more pages have non-empty content but yielded no text (this is EXPECTED for PDFs using subset fonts without /ToUnicode CMaps — it is not an error). The accompanying extractableReason field explains why. Encrypted PDFs are rejected with EXTRACTION_UNSUPPORTED. Tagged-mode structure-tree extraction (cleaner output for tagged PDFs) is tracked on the roadmap.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | No | Optional 0-based page indices to extract. When omitted, every page is extracted. | |
| fields | No | Optional dot-path projection applied to the structured result (e.g. ['fullText'] or ['extractable']). Composes after verbosity. Unknown paths are omitted. | |
| pdfBase64 | Yes | Base64-encoded PDF bytes. | |
| verbosity | No | Response verbosity. 'full' (default) returns the per-page pages[] array and fullText; 'summary' returns a token-frugal { pageCount, extractedPageCount, extractable, charCount } and drops the text payloads. | full |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | Yes | ||
| fullText | Yes | ||
| pageCount | Yes | ||
| extractable | Yes | False when one or more requested pages had a non-empty content stream but yielded no extractable text (likely subset fonts without /ToUnicode). | |
| extractableReason | No | Human-readable explanation when extractable=false. Absent when extractable=true. | |
| extractedPageCount | Yes |