pdf_extract
Extract text, images, tables, metadata, fonts, links, and outlines from PDFs to retrieve structured content for analysis or processing.
Instructions
Extract content and metadata from a PDF.
Supports text, images, tables, metadata, fonts, links, and outline extraction through a single portmanteau tool.
Args are validated and documented via Annotated fields on the signature.
Return Format
A dict with keys:
success: bool - whether the operation succeeded
message: str - human-readable summary
operation-specific keys:
text: {text, pages, page_count}
images: {images: [{page, index, width, height, path, ext}]}
tables: {tables: [{page, rows, cols, headers, data}]}
metadata: {metadata: {...}}
fonts: {fonts: [{name, type, encoding, embedded, size}]}
links: {links: [{page, uri, page_target, rect}]}
outline: {outline: [{title, level, page, children}]} On failure: {success: False, error, error_type}.
Examples
await pdf_extract(operation="text", path="report.pdf", pages="1-3") {"success": true, "text": "...", "pages": 3, "page_count": 12, "message": "Extracted 3 pages of text from report.pdf."}
await pdf_extract(operation="metadata", path="report.pdf") {"success": true, "metadata": {"title": "Report", ...}, "message": "Extracted metadata from report.pdf."}
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to the PDF file. | |
| pages | No | Optional page range (e.g. '1-5,7,9-12'). All pages if omitted. | |
| operation | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| message | No | Human-readable summary | |
| success | No | Whether the operation succeeded |