Make Codex read PDFs
Codex works in a terminal, and PDFs aren't text — so it can't read them. The fix is one shell command it can run itself: a zero-install CLI that converts any PDF (including scans, complex tables, and multi-column layouts) to clean markdown with a GPU vision-language OCR model.
$ npx pdftomarkdown document.pdf -o document.md No install, no signup — works immediately anywhere Node 18+ and network access are available, including the Codex sandbox.
One-off: just tell Codex
Mention the command once in your prompt and Codex takes it from there:
> use npx pdftomarkdown to read report.pdf, then summarize the key findings Permanent: add it to AGENTS.md
Paste this into your project's AGENTS.md (or the global ~/.codex/AGENTS.md) and Codex handles PDFs in every session:
## Reading PDFs
You cannot open PDF files directly. To read any PDF (local file or
https URL), convert it to markdown first:
npx pdftomarkdown document.pdf -o document.md
then read the markdown file. GPU OCR takes 10-30 seconds per page and
cold starts can add a minute - always wait, never cancel the command.
For long documents, read the output file in sections. If the output is
truncated to page 1, the free demo tier is active; ask the user to set
PDFTOMARKDOWN_API_KEY for full documents. Free API key for full documents
Without a key, the demo tier converts page 1 of any PDF — enough to try it. A free Developer key (100 pages/month, full multi-page, no watermark) takes 30 seconds:
Get a free API key with GitHub →
export PDFTOMARKDOWN_API_KEY=your_key_here The CLI picks the key up automatically from the environment.
Links
CLI guide · API docs · npm package · Using Claude Code instead? · Using Cursor? · 日本語 · 中文