# PDF to Markdown for AI & RAG: Tables, OCR, Chunks (`xsi/pdf-to-markdown`) Actor

PDF to Markdown for LLMs and RAG: give PDF URLs, get clean Markdown with headings, lists, tables, 2-column papers in reading order, headers/footers removed, page-cited chunks, metadata and links. OCR for scans at $0.005/page. $2 per 1,000 PDFs (100 pages included), no start fee, failures free.

- **URL**: https://apify.com/xsi/pdf-to-markdown.md
- **Developed by:** [Bilal Belferkous](https://apify.com/xsi) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 pdf converteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## PDF to Markdown for AI & RAG: tables, OCR, page-cited chunks

PDF to Markdown converts PDF links into clean Markdown with headings, lists, tables and two-column reading order, plus RAG-ready chunks that cite page numbers, with OCR for scanned pages in 7 languages.

> **What it does:** Converts PDFs from URLs (including Drive, Dropbox and arXiv links) into clean Markdown with headings, lists and tables, plus RAG chunks that cite page numbers, with optional OCR for scanned pages in 7 languages.
>
> **Who it's for:** AI engineers building RAG and document agents, analysts and researchers who need PDF text in a usable format.
>
> **Price:** $0.002 / PDF (first 100 pages included), $0.005 per scanned page (OCR), no start fee, errors and failed items are not charged. Works through the Apify API, as an MCP tool (`https://mcp.apify.com?tools=xsi/pdf-to-markdown`), and in Zapier, Make, n8n and LangChain via Apify's integrations.

**Give PDF links, get clean Markdown ready for an LLM.** The Actor downloads each PDF, rebuilds its structure (headings, paragraphs, lists, **tables**, 2-column reading order), removes running headers, footers and page numbers, reads **scanned pages with OCR**, and returns the full Markdown plus **RAG-ready chunks** that carry their section heading and page numbers, so your agent can cite "page 4".

Use it to feed papers, reports, contracts, manuals, invoices or tender documents to ChatGPT, Claude, a vector database (Pinecone, Qdrant, Weaviate…), LangChain, LlamaIndex, n8n or Make, or to an Apify AI agent through MCP.

Part of **xsi**: small, honest, pay-per-result tools.

- ✅ **Structure, not a wall of text.** Headings from font sizes, bold sub-headings, bullet and numbered lists, Markdown tables (sparse rows with empty cells included), words split by line-end hyphens re-joined, links kept.
- ✅ **Reads papers in the right order.** 2-column layouts are read column by column, with titles and abstracts that span both columns kept on top.
- ✅ **No noise in your embeddings.** Running headers, footers and "Page 3 of 12" are detected across pages and removed.
- ✅ **Scanned PDFs too.** Image-only pages are OCRed (Tesseract) in English, French, German, Spanish, Italian, Dutch or Portuguese. Pages with a text layer are never OCRed or billed as OCR.
- ✅ **Chunks for RAG.** ~800-token chunks (you choose), a new chunk at each heading, tables never split, overlap inside a section, each with `heading`, `pages` and `tokens`.
- ✅ **Any link.** Direct PDF URLs, Google Drive and Dropbox share links, GitHub `blob` links, arXiv abstract pages, and landing pages that point to their PDF (`citation_pdf_url`, as on most journals and repositories).
- ✅ **You only pay for converted PDFs.** Failed downloads (403, 404, login pages), non-PDFs, password-protected, corrupt and empty PDFs are **free**, with a clear `errorType`.

### Pricing: $2 per 1,000 PDFs, first 100 pages included

| Event | Free plan | Bronze | Silver | Gold / Platinum / Diamond |
|---|---|---|---|---|
| `pdf-converted`: one PDF, first 100 pages included | $0.002 | $0.0018 | $0.0016 | $0.0015 |
| `pages-100`: only for long PDFs, each started block of 100 pages after the first 100 | $0.002 | $0.002 | $0.002 | $0.002 |
| `ocr-page`: one scanned page read by OCR | $0.005 | $0.0045 | $0.004 | $0.0035 |

**No start fee, no per-page fee for normal PDFs.** A 15-page paper costs $0.002; a 250-page report costs $0.006; a 10-page scan costs $0.052. Pages you exclude (`pages`, `maxPagesPerPdf`) aren't counted, and OCR pages where nothing is found are free. Your **Maximum cost per run** is always respected: the Actor reserves the cost before working, converts only the pages it can pay for, and says so in `notes`.

For comparison (public Apify Store pages, 26 Nov 2026), popular PDF Actors charge $0.003–0.005 per PDF **plus a start fee** ($0.001–0.005 per run), some add $0.001 per page, and OCR costs up to **$0.015 per page**.

### Quick start

```json
{ "urls": ["https://arxiv.org/abs/1706.03762", "https://drive.google.com/file/d/<id>/view"] }
```

A scanned French document, pages 1-20 only, with plain text too:

```json
{ "urls": ["https://example.org/scan.pdf"], "ocrLanguages": ["fra"], "pages": "1-20", "includeText": true }
```

| Input | Default | What it does |
|---|---|---|
| `urls` | — | PDF links (direct, share links, landing pages). |
| `pages` | all | Page range, e.g. `1-5, 8, 10-`. |
| `ocr` | `auto` | `auto` = only image-only pages; `always`; `off`. |
| `ocrLanguages` | `["eng"]` | Up to 3 of `eng`, `fra`, `deu`, `spa`, `ita`, `nld`, `por`. |
| `chunkSizeTokens` / `chunkOverlapTokens` | `800` / `100` | `0` = no chunks. |
| `includePages` / `includeText` / `includeLinks` | `true` / `false` / `true` | Per-page Markdown, plain text, links. |
| `maxPagesPerPdf` / `maxOcrPagesPerPdf` | `500` / `50` | Safety limits per PDF. |
| `password` | — | For password-protected PDFs you own. |
| `maxFileSizeMb` | `50` | Bigger files are skipped for free (give the run 2-4 GB of memory for files over 50 MB). |
| `maxConcurrency` | `2` | PDFs in parallel (~300 MB each). |
| `requestTimeoutSecs` / `maxSecondsPerPdf` | `120` / `600` | Download timeout, time budget per PDF. |

### Output (one row per PDF)

Real row from a platform run (26 Nov 2026, build 1.0.8), `markdown`, `pages` and `chunks` shortened:

```json
{
  "input": "https://arxiv.org/abs/1512.03385",
  "url": "https://arxiv.org/pdf/1512.03385",
  "resolvedFrom": "arXiv abstract page converted to its PDF",
  "fileName": "1512.03385v1.pdf",
  "fileSizeBytes": 819383,
  "sha256": "1e0651b6810ecba34a3dbc5b5b0209226f889004607c1f203540a48d64e5a93a",
  "title": "Deep Residual Learning for Image Recognition",
  "pageCount": 12,
  "pagesConverted": 12,
  "language": "en",
  "wordCount": 8373,
  "tokensEstimate": 15343,
  "markdown": "# Deep Residual Learning for Image Recognition\n\n…\n\n## Abstract\n\nDeeper neural networks are more difficult to train. …",
  "pages": [{ "page": 1, "markdown": "…", "ocr": false, "chars": 4407, "links": ["http://image-net.org/challenges/LSVRC/2015/"] }],
  "chunks": [{ "index": 2, "heading": "1. Introduction", "pages": [1, 2], "text": "## 1. Introduction\n\nDeep convolutional neural networks …", "tokens": 763 }],
  "links": ["http://image-net.org/challenges/LSVRC/2015/", "…"],
  "metadata": { "creator": "LaTeX with hyperref package", "producer": "pdfTeX-1.40.12", "createdAt": "2015-12-11T01:13:45.000Z", "pdfVersion": "1.5" },
  "ocrPages": [],
  "pagesNotRead": [],
  "notes": [],
  "seconds": 0.5,
  "charged": true
}
```

Other platform runs the same day: the 15-page "Attention Is All You Need" paper → 9,674 tokens and 24 chunks in 2.1 s, its results table rebuilt as a Markdown table; a 1946 typewritten scan (2 image-only pages) read by OCR in 79 s in total on 1 GB of memory (more memory = faster OCR); a password-protected file and a 404 link returned free error rows.

PDFs that can't be converted get one free row with `errorType`: `invalid_input`, `invalid_url`, `dns_error`, `connection_error`, `tls_error`, `timeout`, `too_many_redirects`, `access_denied` (401/403 or a login page), `not_found`, `http_error`, `file_too_large`, `not_a_pdf`, `password_protected`, `corrupt_pdf`, `no_text`, `scanned_no_text` (OCR off or unavailable) or `max_cost_reached`. The **OUTPUT** record summarises PDFs converted, pages, OCR pages and free rows.

The dataset has two views: **Overview** (one row per PDF) and **Chunks** (one row per chunk, ready to embed).

### AI agent use cases (MCP, LLM frameworks, automation)

- **Read a PDF found during research:** an agent passes the link through the MCP tool and gets Markdown it can quote with page numbers.
- **RAG ingestion:** send the `chunks` (with section heading and pages) to a vector database through LangChain, LlamaIndex or your own code.
- **Document pipelines:** n8n or Make picks up new PDF links (tenders, reports, invoices) and stores the Markdown.
- **Scanned documents:** turn on OCR only when needed; pages where OCR finds nothing are free.

How to connect it:

- **Any MCP client** (Claude Desktop, Cursor, ChatGPT connectors, your own agent): add the Apify MCP server `https://mcp.apify.com/?tools=xsi/pdf-to-markdown` and the Actor becomes a tool.
- **LLM frameworks:** call it from LangChain or LlamaIndex with Apify's integrations, or from any code through the Apify API (one POST, JSON back).
- **No-code automation:** n8n, Make and Zapier have Apify nodes: run it on a schedule or a trigger and send the rows to Sheets, a CRM or Slack.

### Use with AI agents (MCP)

Available through the Apify MCP server (`https://mcp.apify.com/?tools=xsi/pdf-to-markdown`). An agent can pass a link it found and get back Markdown it can quote with page numbers; errors come back as data, never as a crashed run.

### Why this one? (problems we fixed from other PDF Actors)

| Problem seen with PDF extractors | What this Actor does | Regression test |
|---|---|---|
| Start fee on every run, extra per-page fees, OCR at $0.015/page | No start fee, 100 pages included, OCR $0.005/page | `P4`, `P9` |
| Paying for failures (login pages, 404s, encrypted files) | All failures are free, with a typed error | `P3`, `P6`, `P8`, `P14` |
| 2-column papers come out interleaved line by line | Column detection, read left then right | `P10`, unit test |
| Tables flattened into one line; sparse rows split into fragments | Column-grid table rebuild, empty cells kept | `P1`, unit tests |
| Page headers/footers repeated in every chunk | Removed when repeated on most pages (but never a page's only content) | unit tests |
| Big-type notices and author footnote markers turned into headings and fake tables (seen in our own first run on arXiv 1706.03762) | Multi-line big-type blocks are paragraphs; superscripts stay on their line | unit tests |
| Heading-only chunks ("title" chunk of 12 tokens) | Consecutive headings stay with their text | unit test |
| Share links (Drive, Dropbox, arXiv, journal pages) return HTML, not the PDF | Links normalised, `citation_pdf_url` followed | `P5`, `P7`, unit test |
| Runs over budget on long documents | Cost reserved before work; partial conversion explained | `P11`, `P12` |

36 automated tests (20 unit + 16 integration) run before every build, on generated PDFs: structured report, 2-column paper, scan, encrypted, blank, 250 pages, corrupt, and an arXiv-like first page.

### Limits (honest)

- Structure is rebuilt with layout heuristics: complex tables (merged cells, multi-line cells, rotated headers) and math formulas can come out simplified; superscripts are written inline (`10^20` reads `1020`).
- OCR quality depends on the scan; Tesseract supports the 7 languages listed. Handwriting isn't supported.
- Password-protected PDFs need the `password`; we never try to break protections.

### Questions people ask

#### How do I convert a PDF to Markdown for an LLM?

Give PDF URLs. Each document returns Markdown and heading-aware chunks with page references.

#### How do I extract tables from a PDF?

Tables are rebuilt as Markdown tables, including rows with empty cells and two-column layouts.

#### Can it read scanned PDFs?

Yes, turn on OCR; it is billed per OCR page ($0.005).

#### How much does PDF to Markdown conversion cost?

$0.002 per PDF (first 100 pages included), $0.002 per extra 100 pages, $0.005 per scanned page (OCR). No start fee; failed downloads and pages where OCR finds no text are free.

#### Can ChatGPT, Claude or my own AI agent use this tool?

Yes. Add Apify's MCP server (`https://mcp.apify.com?tools=xsi/pdf-to-markdown`) to Claude, ChatGPT, Cursor or any MCP client and authenticate with your Apify token. Agents can also call it with the Apify API, or pay without an account by buying a capped prepaid token at agi.apify.com (x402, card).

#### Is there a free trial?

Apify's free plan includes monthly platform credit, which covers many runs at these prices. You only pay for results; failures are free.

### Comparison with alternatives

| Tool | Price | Start fee | Users (30 days) |
|---|---|---|---|
| **xsi/pdf-to-markdown** (this Actor) | $0.002 / PDF | no | new |
| memo23/pdf-text-extractor | $0.005 / PDF, OCR $0.015 / page | $0.005 | 177 |
| gochujang/pdf-text-extractor | $0.005 / PDF + $0.001 / page | $0.001 | 30 |

*Competitor prices and 30-day user counts: public Apify Store API, checked 26 Nov 2026. Prices change, so check each page before buying.*

**Keywords:** pdf to markdown, pdf to text api, pdf for rag, extract tables from pdf, pdf ocr api, document parsing for llm

### FAQ

**Is it legal?** The Actor downloads only the links you give (or the PDF a landing page declares), with an honest user agent and no login. Convert documents you're allowed to use.

**What runs inside?** [pdf.js](https://github.com/mozilla/pdf.js) (Apache-2.0) for text and layout, Poppler and [Tesseract](https://github.com/tesseract-ocr/tesseract) (Apache-2.0) for OCR. Files are processed in the run's container and not kept after the run.

**A PDF comes out badly?** Open an issue on the **Issues** tab with the link: every confirmed case becomes a regression test.

### Changelog

- **1.0.13 (29 Nov 2026)**: Docs only: the input schema and README now state the live OCR price ($0.005 per scanned page on the Free plan, matching the `ocr-page` event). Prices and PPE unchanged.

# Actor input Schema

## `urls` (type: `array`):

Direct PDF links, or pages that point to a PDF (arXiv, journals with citation_pdf_url), Google Drive / Dropbox share links (public files) and GitHub file pages. Up to 1,000 per run.

## `pages` (type: `string`):

Only convert these pages, e.g. "1-5, 8, 10-". Empty = all pages (up to "Max pages per PDF").

## `ocr` (type: `string`):

auto = only pages without a text layer (scans) are read with OCR ($0.005/page on the Free plan). off = never. always = OCR every page (for PDFs with a broken text layer).

## `ocrLanguages` (type: `array`):

Up to 3 of: eng, fra, deu, spa, ita, nld, por.

## `chunkSizeTokens` (type: `integer`):

Approximate size of each chunk in "chunks" (1 token ≈ 4 characters). A new chunk starts at each heading; tables are never split. 0 = no chunks.

## `chunkOverlapTokens` (type: `integer`):

Text repeated from the end of the previous chunk (same section only).

## `includePages` (type: `boolean`):

Also return each page separately (page number, Markdown, OCR flag, links).

## `includeText` (type: `boolean`):

Also return a plain-text version without Markdown symbols.

## `includeLinks` (type: `boolean`):

Return the web links found in the PDF.

## `maxPagesPerPdf` (type: `integer`):

Longer documents are cut here (cost control). The first 100 pages are included in the per-PDF price; each further started block of 100 pages costs $0.002.

## `maxOcrPagesPerPdf` (type: `integer`):

Upper limit of scanned pages read per PDF (cost control).

## `password` (type: `string`):

For password-protected PDFs you are allowed to open. Used only to open the file in this run.

## `maxFileSizeMb` (type: `integer`):

Bigger files are skipped for free. Bigger files need more memory: give the run 2-4 GB for files over 50 MB.

## `maxConcurrency` (type: `integer`):

How many PDFs are processed at the same time. Each PDF in parallel needs ~300 MB: keep 2 at 1 GB memory, raise memory before raising this.

## `requestTimeoutSecs` (type: `integer`):

Give up on a download after this many seconds (free).

## `maxSecondsPerPdf` (type: `integer`):

Very long or heavy PDFs stop here and return the pages done so far (with a note).

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "chunkSizeTokens": 800,
  "chunkOverlapTokens": 100,
  "includePages": true,
  "includeText": false,
  "includeLinks": true,
  "maxPagesPerPdf": 500,
  "maxOcrPagesPerPdf": 50,
  "maxFileSizeMb": 50,
  "maxConcurrency": 2,
  "requestTimeoutSecs": 120,
  "maxSecondsPerPdf": 600
}
```

# Actor output Schema

## `results` (type: `string`):

No description

## `chunks` (type: `string`):

No description

## `summary` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "urls": [
        "https://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("xsi/pdf-to-markdown").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "urls": ["https://arxiv.org/pdf/1706.03762"] }

# Run the Actor and wait for it to finish
run = client.actor("xsi/pdf-to-markdown").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call xsi/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,xsi/pdf-to-markdown"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/F0Om63ajJskIYGbdS/builds/D5OaBMXnSNhg6bZGl/openapi.json
