PDF to Markdown for AI agents avatar

PDF to Markdown for AI agents

Pricing

from $3.00 / 1,000 pdf documents

Go to Apify Store
PDF to Markdown for AI agents

PDF to Markdown for AI agents

Convert PDF URLs to clean Markdown for LLMs, RAG and AI agents: headings, per-page text and metadata. Flat price per PDF; locked, scanned or failed PDFs are free.

Pricing

from $3.00 / 1,000 pdf documents

Rating

0.0

(0)

Developer

Lundrik

Lundrik

Maintained by Community

Actor stats

0

Bookmarked

2

Total users

1

Monthly active users

10 days ago

Last modified

Categories

Features

Limited permissions

Share

PDF to Markdown for AI agents — with OCR for scanned PDFs

Turn PDF links into clean Markdown that LLMs, RAG pipelines and AI agents can read: headings, paragraphs, bullet lists, page markers, per-page text and document metadata. Scanned pages are read with built-in OCR (8 languages), and you only pay for PDFs that were converted — locked, broken, empty or unreachable files are free.

Why this Actor

This ActorTypical PDF text extractors
Scanned pages✅ OCR only on pages that need it (ocr: auto) – normal PDFs stay fastOften all-or-nothing, or no OCR
Mixed PDFs (text + scanned pages)✅ text layer where it exists, OCR where it does notOne method for the whole file
Broken / garbled text layer✅ ocr: force re-reads the pages with OCRGarbage text returned as-is
Lithuanian, Polish, German, French, Spanish, Italian, Portuguese, English✅ choose 1–3 OCR languagesUsually English only
Failed, locked, empty files✅ free, with a clear error codeOften charged or silently empty
Start fee✅ none (only Apify's tiny standard fee)Often $0.005 per run
Markdown structure✅ headings, lists, page markers, per-page textPlain text
Password-protected PDFs✅ pdfPassword (your own documents)Often unsupported

What you get

  • Markdown with structure – headings (#, ##, ###) detected from font sizes, paragraphs re-joined across line breaks (including hyphenated words), bullet lists as - item.
  • OCR for scanned pages – open-source Tesseract runs inside the Actor (no third-party API, your files are not sent anywhere). Each OCR page is marked ocr: true in pageTexts; ocrPages and ocrConfidence (0–100) are in every row.
  • Page markers – <!-- page 3 --> before every page, so you can cite page numbers.
  • Per-page Markdown (pageTexts) – one entry per page, ready for chunking.
  • Metadata – title, author, subject, keywords, creator, producer, creation and modification date, language, PDF version, page count. If the PDF has no title, the main heading of the first pages is used.
  • Links found in the PDF (URL annotations).
  • A .md file for every document in the key-value store (markdownUrl) – also for very large documents that do not fit into a dataset row.
  • Clear errors instead of empty output: wrong password, empty scan, not a PDF, too large, unreachable.

OCR in short

ocrWhat happensUse it for
auto (default)A page is OCR'd only if it contains an image and has almost no text layer. Blank pages are skipped.Everyday mix of digital and scanned PDFs
forceThe first maxOcrPages pages are OCR'd and the OCR text replaces their text layer (if OCR found text); later pages keep their text layer.Old scans with a garbled "invisible" text layer
offNo OCR. A scanned PDF returns PDF_NO_TEXT_LAYER (free).Maximum speed, digital PDFs only
  • ocrLanguages: en, de, fr, es, it, pt, lt, pl (1–3 at once; Tesseract codes like eng, lit also work). Choose the document language – it matters for letters like ą, č, ė, ł, ß, é.
  • maxOcrPages (default 3, max 5): OCR takes a few seconds per page, so the number of OCR pages per PDF is limited. Scanned pages above the limit stay empty, are listed in ocrSkippedPages, explained in note and not charged (they are not counted in pagesCharged).
  • OCR pages give paragraphs and lists; headings are guessed from larger text lines. Tables come out as text lines.
  • Handwriting is not supported.

Input

FieldDefaultDescription
urls– (required)Direct links to PDF files. Redirects are followed. Duplicates are removed.
ocrautoauto, force or off (see above).
ocrLanguages["en"]OCR languages, 1–3 of en de fr es it pt lt pl.
maxOcrPages3Max pages read with OCR per PDF (0–5). Unread scanned pages are not charged.
pdfPassword–Password for protected PDFs you are allowed to open. Stored as a secret input, never written to results.
maxFileSizeMb50Files above this size are not downloaded (max 100).
maxPages1000Only the first N pages are converted and charged.
includePageTextstrueAdd pageTexts (Markdown per page).
downloadTimeoutSecs60Time limit for downloading one file.
maxConcurrency0 (auto = 3)PDFs processed in parallel.
{
"urls": ["https://bitcoin.org/bitcoin.pdf", "https://example.com/scanned-contract.pdf"],
"ocr": "auto",
"ocrLanguages": ["en", "lt"]
}

Output

One dataset row per PDF (example, shortened):

{
"url": "https://bitcoin.org/bitcoin.pdf",
"status": "ok",
"title": "Bitcoin: A Peer-to-Peer Electronic Cash System",
"pages": 9,
"pagesConverted": 9,
"markdown": "<!-- page 1 -->\n\n# Bitcoin: A Peer-to-Peer Electronic Cash System\n\nSatoshi Nakamoto ...",
"pageTexts": [{ "page": 1, "markdown": "# Bitcoin: A Peer-to-Peer Electronic Cash System ..." }],
"metadata": { "title": "Bitcoin: A Peer-to-Peer Electronic Cash System", "creator": "Writer", "producer": "OpenOffice.org 2.4", "creationDate": "2009-03-24T11:33:15Z", "language": "en-GB", "pdfVersion": "1.4" },
"ocrPages": [],
"ocrSkippedPages": [],
"ocrConfidence": null,
"markdownChars": 21517,
"markdownUrl": "https://api.apify.com/v2/key-value-stores/.../records/bitcoin-org-bitcoin-pdf-1a2b3c4d.md?signature=...",
"charged": "pdf-document",
"errorCode": null
}

A scanned PDF looks the same, with "ocrPages": [1, 2, 3], "ocrConfidence": 93, "ocrLanguages": ["eng"] and "ocr": true on those pages in pageTexts.

  • status: ok (converted – charged), error (see errorCode – free), skipped (your maximum cost per run was reached – free).
  • Documents with more than 30 charged pages also have chargedExtra: { "event": "pdf-extra-page", "count": N }. pagesCharged = converted pages minus scanned pages that were not read with OCR.
  • If the Markdown is too large for a dataset row (several MB), markdown and pageTexts are null and the full text is in markdownUrl.

Error codes (all free of charge)

CodeMeaning
PDF_ENCRYPTEDThe PDF needs a password. Add it in pdfPassword if you are allowed to open the file. We do not crack passwords.
PDF_PASSWORD_INCORRECTThe password in pdfPassword is wrong.
PDF_NO_TEXT_LAYERNo readable text: blank pages, an unreadable scan, OCR turned off, or maxOcrPages = 0.
PDF_INVALIDThe file is damaged or not a readable PDF.
NOT_PDFThe URL returned something else (a web page, a ZIP…). Use a direct link to the .pdf.
FILE_TOO_LARGEThe file is larger than maxFileSizeMb.
HTTP_ERRORThe server returned 404, 500…
BLOCKED_BY_BOT_PROTECTIONThe server refused automated access (HTTP 401/403/429). We do not bypass protection.
TIMEOUT, CONNECTION_FAILED, SSL_ERROR, DNS_NOT_FOUND, INVALID_URLThe file could not be downloaded.

Pricing

EventPriceWhen
pdf-document$0.003 per PDFEach PDF converted successfully – includes the first 30 pages, also when some pages were read with OCR.
pdf-extra-page$0.0002 per pageEach converted page above 30 in the same PDF (scanned pages not read with OCR do not count).

Examples: a 10-page PDF = $0.003; a 3-page scanned letter read with OCR = $0.003; a 100-page PDF = $0.003 + 70 × $0.0002 = $0.017; 1,000 short PDFs = $3.00.

  • Failed, locked, empty and too-large PDFs are free.
  • Use maxPages to cap the price of very long documents.
  • Apart from the tiny Apify start fee (Apify standard, $0.00005 per GB of memory per run), you pay only for converted PDFs.
  • Set Maximum cost per run in the run options: a PDF whose pages would not fit into the remaining budget is not converted (marked skipped, free).

Use with AI agents (MCP)

The Actor is a ready-made tool for AI agents through the Apify MCP server: the agent passes PDF links and reads Markdown back.

{
"mcpServers": {
"apify": {
"url": "https://mcp.apify.com/?tools=lundrik/pdf-to-markdown",
"headers": { "Authorization": "Bearer <YOUR_APIFY_TOKEN>" }
}
}
}

Example prompt: "Read https://example.com/annual-report.pdf with the PDF to Markdown tool and list the three biggest risks with page numbers." The agent gets markdown with <!-- page N --> markers (or pageTexts for citations).

From code (JavaScript):

import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('lundrik/pdf-to-markdown').call({ urls: ['https://bitcoin.org/bitcoin.pdf'], ocrLanguages: ['en'] });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].markdown);

FAQ

My scanned PDF came back with only some pages. OCR is limited by maxOcrPages (max 5 per PDF). The row lists the pages that were not read in ocrSkippedPages; they are not charged. Split long scans or convert the important pages first.

The OCR text has mistakes. Check that ocrLanguages matches the document and look at ocrConfidence (below ~70 = poor scan). Low-resolution, skewed or handwritten pages give weaker results.

Can I OCR a PDF that already has text? Yes – ocr: "force" re-reads the first maxOcrPages pages. Useful when copy-paste from the PDF gives garbage.

Is my document sent to a third-party OCR service? No. OCR runs inside the Actor with open-source Tesseract.

Does it extract tables? Tables come out as text lines, not Markdown tables.

Can I use files from Google Drive or Dropbox? Use a direct download link that returns the PDF itself (not a preview page).

Notes

  • Only files you link to are downloaded; nothing else is crawled.
  • Private and local network addresses are blocked.
  • You are responsible for having the right to process the documents you submit.
  • OCR: Tesseract via tesseract.js (Apache-2.0), tessdata_fast models (Apache-2.0).