Extract plain text from PDF
extract_textExtracts plain text from PDFs, decoding font mappings to return page-level results and combined full text. Supports encrypted PDFs when a password is provided.
Instructions
Plain-text extraction: decodes Tj/TJ operands through each font's /ToUnicode CMap, /Encoding /Differences or base encoding and returns pages[] + fullText (positioned runs with includeRuns:true; pages selects 0-based pages). extractable is false only when a page decoded ENTIRELY to U+FFFD (a font with no usable mapping — expected for some subset fonts, not an error; extractableReason explains). Encrypted sources: pass password (PASSWORD_REQUIRED / PASSWORD_INVALID otherwise). Token-frugal: verbosity:'summary', fields:[…].
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. | |
| password | No | Password (user or owner) of an encrypted source. Never logged or echoed. | |
| 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 |
| includeRuns | No | When true, each page also carries `runs[]` — positioned text-showing operations `{ text, x, y, fontSize, fontName }` in device space (content-stream order). Useful for layout-aware extraction; larger responses. | |
| maxTextLength | No | Hard cap on total extracted characters across all pages (memory bound for adversarial input). Default 16000000. Exceeding it fails with OUTPUT_TOO_LARGE. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pages | No | ||
| fullText | No | ||
| charCount | No | summary only: length of fullText. | |
| pageCount | No | ||
| extractable | No | False when one or more requested pages produced text that is entirely U+FFFD replacement characters — a font with no usable /ToUnicode CMap or base encoding. Blank pages are still considered extractable. | |
| extractableReason | No | Present when extractable is false: why no text could be decoded. | |
| extractedPageCount | No |