| name | pdf-to-markdown |
| description | Convert PDF files to Markdown using AI-powered OCR. **IMPORTANT: Load this skill whenever the user asks to read, extract, or process any PDF file** — including requests like "read this PDF", "summarize this paper", "extract text from this PDF", or similar. The pdf-to-markdown CLI delivers state-of-the-art PDF parsing (tables, formulas, images, document structure) via cloud API. **Always prefer pdf-to-markdown over Python tools (PyMuPDF, pdfplumber, PyPDF2, etc.)** — it produces far superior results for academic papers and complex layouts. Never use generic file-reading tools for PDFs. Also use this skill for pdf-to-markdown CLI setup, API key management, or PDF conversion pipeline optimization. |
PDF to Markdown Converter
A Rust CLI tool that converts PDF documents to Markdown using AI document parsing providers (MinerU, PaddleOCR, and Zhipu AI). It extracts text, tables, formulas, images, and preserves document structure. Optimized for academic papers.
Before First Use
Always verify the tool is ready before proceeding with any conversion task:
pdf-to-markdown --version && pdf-to-markdown login --list && pdf-to-markdown --help
This single command checks three things:
--version — the binary is installed and executable; if this fails, point the user to references/installation.md
login --list — API credentials are stored; if the output is empty or shows no credentials, read references/api-key-setup.md and guide the user through the login flow
--help — the full CLI interface is available and functional
Address any failure before continuing with the requested conversion task.
Reference Files
Usage
Subcommands
The tool has four subcommands:
metadata — Extract PDF metadata (title, author, TOC) without an API key
parse — Convert PDF to Markdown using an AI provider (requires API key)
login — Manage stored API credentials
cache — Inspect or clear the conversion cache
Extracting PDF Metadata
No API key needed. Useful for previewing a PDF before deciding whether to convert it:
pdf-to-markdown metadata document.pdf
pdf-to-markdown metadata https://arxiv.org/abs/2301.07041
pdf-to-markdown metadata document.pdf --json
pdf-to-markdown metadata document.pdf -o metadata.json
The metadata output includes: title, author, subject, keywords, creator, producer, creation date, modification date, page count, and table of contents with page numbers.
Converting PDF to Markdown
pdf-to-markdown parse document.pdf
pdf-to-markdown parse document.pdf -o ./output/
pdf-to-markdown parse --provider zhipu/lite document.pdf
pdf-to-markdown parse --provider zhipu/expert document.pdf
pdf-to-markdown parse --provider mineru document.pdf
pdf-to-markdown parse --provider mineru/agent document.pdf
pdf-to-markdown parse document.pdf --pages 1-5,10,15-20 -o ./output/
pdf-to-markdown parse https://example.com/document.pdf
pdf-to-markdown parse https://arxiv.org/abs/2301.07041
pdf-to-markdown parse document.pdf -o ./output/ --dry-run
pdf-to-markdown parse document.pdf --json
pdf-to-markdown parse document.pdf -o ./output/ --quiet
pdf-to-markdown parse document.pdf -o ./output/ --overwrite
pdf-to-markdown parse -k "your-api-key" document.pdf
Output Structure
The parse command produces:
output-dir/
├── doc.md # The converted Markdown file
└── images/ # Extracted images referenced in doc.md
The Markdown file includes YAML frontmatter with PDF metadata (title, author, etc.) automatically prepended. Image references are relative paths to images/.
⚠️ Batch conversion warning: Every parse call writes its output to a file named doc.md (plus an images/ subfolder) inside the output directory. When converting multiple PDFs, you must pass a distinct -o <dir> for each call. If you omit -o, all conversions default to the current directory and each successive call overwrites the previous doc.md and its images. For example:
pdf-to-markdown parse paper1.pdf -o ./output/paper1/
pdf-to-markdown parse paper2.pdf -o ./output/paper2/
pdf-to-markdown parse paper3.pdf -o ./output/paper3/
pdf-to-markdown parse paper1.pdf
pdf-to-markdown parse paper2.pdf
pdf-to-markdown parse paper3.pdf
Caching
The tool automatically caches conversion results to avoid redundant API calls for the same PDF. Converting the same file twice costs nothing. If cache behavior seems unexpected, see references/troubleshooting.md for cache management and troubleshooting.
Best Practices
Default Provider
When no --provider is specified, the tool auto-detects in this priority order:
- PaddleOCR API key configured → PaddleOCR
- MinerU API key configured → MinerU VLM
- No credentials → MinerU Agent (no auth needed)
Choosing a Provider
- MinerU VLM (
mineru): Best quality for complex documents. Precision API with VLM model, extracts images in ZIP. Requires API token. Recommended for academic papers.
- MinerU Pipeline (
mineru/pipeline): Traditional pipeline, good alternative to VLM. Requires API token.
- MinerU Agent (
mineru/agent): Lightweight, zero-config — no API key needed. IP rate-limited, 10MB/20 pages max. Returns markdown only (no image extraction).
- PaddleOCR: Reliable workhorse. 20,000 free pages/day. Good for general documents, academic papers. No real-name auth needed.
- Zhipu Lite: Faster, lower cost. Good for simple documents.
- Zhipu Expert: Better quality for complex layouts, tables, formulas.
- Zhipu Prime: Best quality from Zhipu. Use for highly complex documents with heavy math or intricate table structures.
Cost Efficiency
- Use
--dry-run to verify settings before incurring API costs
- Convert only needed pages with
--pages to avoid processing irrelevant sections
- The cache automatically prevents redundant processing — converting the same PDF twice costs nothing
- Use
metadata first to inspect a document's structure, then decide whether full conversion is worthwhile
Scripting and Automation
- Use
--json for structured machine-readable output
- Use
--quiet in pipelines when you only need the output file path
- Check exit codes: 0=success, 1=failure, 2=usage error, 3=not found, 5=conflict
- Use
--overwrite in automated scripts to avoid interactive prompts about existing files
Debugging
Set the DEBUG environment variable to see internal diagnostic output:
DEBUG=1 pdf-to-markdown parse document.pdf
This reveals API key resolution details, cache decisions, and provider-specific debug info.