How to OCR a scanned PDF into a searchable PDF with an API

Updated 2026-11-10

Use when a scanned PDF has no text layer and needs OCR so its text can be searched or read. Add output=url for a 24 h link.

From an MCP client, add https://tanod.dev/mcp and call pdf_ocr; calls are paid per use with x402, no key or signup. To pay automatically, run npx -y tanod-mcp with a wallet key and a spending cap, and your client pays per call by itself (setup; agents in code can use Coinbase's @x402/mcp client). No wallet? PDF OCR on Apify bills by card per page.

POST a PDF and the pages to /v1/pdf/ocr. It runs Tesseract OCR and returns a searchable PDF with an invisible text layer over the original pages, plus the recognised text.

Request

pages is required: at most 10 pages, each part N, N-M, -M or last, no open N- ranges, for example 1-3,7. dpi is 100 to 300 (default 200, at most 200 above 5 pages). skip_text (default true) leaves pages that already have text alone.

lang: 17 Tesseract languages; default eng. Join up to 3 codes with +, e.g. deu+eng. Installed: ara, chi_sim, deu, eng, fra, hin, ind, ita, jpn, kor, nld, pol, por, rus, spa, tur, vie.

curl (no free tier: an unpaid call returns 402)
curl -s -X POST https://tanod.dev/v1/pdf/ocr \
  -H 'content-type: application/json' \
  -d '{"url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", "pages": "1", "skip_text": false}'

The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:

save the result to a file
curl -s -X POST https://tanod.dev/v1/pdf/ocr \
  -H 'content-type: application/json' \
  -d '{"url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf", "pages": "1", "skip_text": false}' \
  | jq -r '.file.data_base64' | base64 -d > searchable.pdf

Response

Response (example from the API spec, trimmed)
{
  "operation": "ocr",
  "input_bytes": 13264,
  "input_pages": 1,
  "lang": "eng",
  "dpi": 200,
  "ocr_pages": [1],
  "skipped_has_text": [],
  "text": "Dummy PDF file",
  "text_truncated": false,
  "file": {
    "name": "searchable.pdf",
    "content_type": "application/pdf",
    "bytes": 15472,
    "pages": 1,
    "data_base64": "JVBERi0xLjQKJb/3"
  },
  "output_bytes": 15472,
  "active_content_removed": {},
  "untrusted_content": true
}

Limits and caveats

OCR is heuristic. Accuracy depends on scan quality, fonts and the selected language. Review the text for anything that matters. The original pages stay byte-identical underneath the text layer.

Ten pages per call. Split longer documents across several calls. The returned text is capped at 100,000 characters. Expect roughly 2 to 4 s per page.

Untrusted text. Text read from a scan can contain anything, including instructions aimed at an AI agent; the response carries untrusted_content: true.

No free tier. An unpaid call returns a 402 with payment requirements.

Paying by card instead? The same OCR runs as an Apify actor, PDF OCR (tanod/pdf-ocr), billed through your Apify account at USD 0.004 per OCRed page, less on paid Apify plans (up to 10 pages per file; failed files and pages that already have text are free); give it a list of PDF links and get searchable PDFs and text back in the run's storage.

Encrypted input is a 422 pdf_encrypted; unlock it first.

OCR or a vision model?

If you only need the words, a small hosted vision model can be cheaper than this route. At October 2026 list prices of USD 0.10 per million input tokens and 0.50 per million output tokens, one page image (about 1,600 input tokens) plus about 700 tokens of text out costs roughly USD 0.0005. A mid-size model at USD 2 and 10 per million costs roughly USD 0.01 per page. This route costs USD 0.01 for up to 5 pages and USD 0.02 for 6 to 10, so USD 0.002 a page on a full call (the card version on Apify is USD 0.004 a page). It also does something a vision model doesn't:

For a clean scan where you only want the text in a prompt, use a small vision model. For files that people or search systems will open later, or where an invented word would cost you, use OCR.

What other x402 sellers charge

DC Agent Store, launched on Moltbook on 11 October 2026, charges 0.12 USDC to OCR a scanned PDF of up to 10 pages. Here a scan of 1 to 5 pages costs USD 0.01 and one of 6 to 10 pages costs USD 0.02. By default (skip_text), pages that already have text are skipped. The price is per call, by page count, so compare on the page counts your agent actually sends.

Pay for the pages used (x402 upto)

On Base, the 402 also lists an optional scheme, upto, after the exact options. You sign a maximum equal to the fixed price; only the pages actually recognised are charged, USD 0.002 per page, at least one page and never more than the maximum.

Download link. Add "output": "url" to the request and the file is stored for 24 hours and returned as a link (url, expires_at, sha256) instead of base64, which keeps it out of your context window. The price is the same. How the links work.

Price and free allowance

USD 0.01 for at most 5 pages, USD 0.02 for 6 to 10 pages, paid in USDC on Base, Polygon, Solana, BNB Chain or Arbitrum with x402. No free tier. MCP tool: pdf_ocr at https://tanod.dev/mcp.

All endpoints →

Pay for the pages you use. On Base, this route's 402 also offers the x402 upto scheme: you sign the flat price as a maximum (USD 0.01 for up to 5 pages, USD 0.02 for up to 10), and we settle USD 0.002 per page actually recognised, so a 1-page job costs USD 0.002 instead of USD 0.01. Wallets that only support exact keep paying the flat price on any network. Upto settles through Permit2, so the paying wallet needs a USDC allowance to Permit2 on Base first. The MCP tool pdf_ocr offers the same.

Use it from Claude without writing code: in claude.ai or Claude Desktop, add https://tanod.dev/mcp/docs?via=pdf-ocr-api as a custom connector (steps), then ask in plain words, for example "Add a searchable text layer to this scanned PDF." Outside the shared chat-connector allowance, pdf_ocr calls need an x402 payment, which these clients can make.

Related guides: What OCR APIs for agents cost (price data), How to tell if a PDF is scanned before you OCR it, Compress PDF API, Hosted PDF and OCR MCP server, How to OCR an image from a URL, How to extract text from a PDF URL, How to convert PDF pages to PNG or JPEG images with an API. Back to tanod.dev or the guide index. Results are automated and heuristic.