PDF to Markdown
ai_pdf_to_markdownConvert text PDFs into structured Markdown with headings, paragraphs, and lists, plus optional page ranges and page markers; scanned PDFs require OCR first.
Instructions
Convert a text PDF to structured Markdown: headings guessed from font size (text clearly larger than the body becomes #, ##, ###), paragraphs rebuilt from line spacing with hyphenated words mended, bullet and numbered lists kept, right-to-left lines in reading order. Optional page range ("1-5, 8") and page markers. Scanned PDFs without a text layer give empty pages (listed in pagesWithoutText; run OCR first). Tables and columns are read line by line. Accepts a local path or base64. Inline Markdown is cut at maxChars (default 200k); "output" saves it to a file.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file | Yes | The PDF: a local file path (absolute, or relative to the server's --root) or base64 data (raw or a data: URI). | |
| pages | No | Pages to convert, e.g. "1-3, 7" or "5-" (1-based). Default: all. | |
| output | No | Write the Markdown to this file (or folder ending in "/") and return its path instead of the inline text. | |
| maxChars | No | Cut the inline Markdown after this many characters, with a note (a file written with "output" is never cut). Default 200000. | |
| password | No | Password, if the PDF is protected. | |
| pageMarkers | No | Put "<!-- Page N -->" before each page and "---" between pages. Default false. |