# PDF to Markdown & Text Extractor for LLM & RAG (`mcpkit/pdf-to-markdown`) Actor

PDF to Markdown and text extractor for AI agents and RAG. Converts PDF, Word, Excel, PowerPoint, CSV and scanned images (optional OCR) from a URL or Base64 into clean Markdown, tables as JSON and RAG-ready chunks with page numbers. Works with Claude, Cursor, n8n and Apify MCP. Pay per document.

- **URL**: https://apify.com/mcpkit/pdf-to-markdown.md
- **Developed by:** [mcpkit](https://apify.com/mcpkit) (community)
- **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 documents converted

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

### What is PDF to Markdown & Text Extractor

PDF to Markdown & Text Extractor converts PDF, DOCX, XLSX, PPTX, CSV and TXT documents, and with optional OCR also scanned PDFs and images, into clean Markdown or plain text for LLMs, AI agents and RAG pipelines. Pass a document URL or a Base64 file and get back one dataset item per document with:

- **Markdown** with headings, paragraphs, lists and tables in reading order.
- **Tables** as Markdown and as JSON rows (PDF ruled tables, Word tables, every Excel sheet, PowerPoint tables).
- **Chunks** of about N characters with overlap and page numbers, ready for a vector store.
- **Metadata**: title, author, creation date, language, page count.

It runs without a browser, so a typical 15-page PDF is converted in about one second. OCR is off by default and runs only on pages without a text layer. The file type is detected from the file content, not the extension. Repeated page headers and page numbers are removed. You pay per converted document; failed documents are not charged.

#### What can you convert

- **PDF to Markdown** and plain text, with headings and reading order preserved.
- **PDF table extractor**: PDF tables to JSON rows and Markdown tables.
- **Word to Markdown**: DOCX headings, lists, bold, italic, links and tables.
- **Excel to JSON** and Markdown: XLSX and CSV, every sheet as a table.
- **PowerPoint to Markdown**: PPTX slides, tables and speaker notes.
- **PDF to RAG chunks** with page numbers, ready for a vector store.
- **Image to text (OCR)**: scanned PDFs and PNG, JPEG, TIFF or WEBP images in 14 languages, with `"ocr": true`.

### How to use

#### Apify Console

1. Open the Actor and paste one or more public document URLs into **Document URLs**.
2. Optionally set **Chunk size** (for example `2000`) and **Page range** (for example `1-5`).
3. Click **Start**. Each document appears as one row in the dataset; open the **Content** view to read the Markdown.

#### API

```bash
curl -X POST "https://api.apify.com/v2/acts/mcpkit~pdf-to-markdown/run-sync-get-dataset-items?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://arxiv.org/pdf/1706.03762"], "chunkSize": 2000}'
```

#### Apify MCP for Claude and Cursor

Add the Actor to your MCP client configuration:

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

Then ask: *"Convert https://arxiv.org/pdf/1706.03762 to Markdown and summarize Table 2."* The agent calls the tool with `{"urls": ["https://arxiv.org/pdf/1706.03762"]}`. AI agents should pass documents as URLs; Base64 input is meant for n8n, Make and API pipelines where the file is already in memory.

#### n8n HTTP Request node

- Method `POST`, URL `https://api.apify.com/v2/acts/mcpkit~pdf-to-markdown/run-sync-get-dataset-items`, query parameter `token` = your Apify API token.
- JSON body with a URL from a previous node:

```json
{ "urls": ["{{ $json.fileUrl }}"], "chunkSize": 1500, "chunkOverlap": 150 }
```

- Or with a binary file from a previous node (up to 6.5 MB):

```json
{ "files": [{ "fileName": "{{ $binary.data.fileName }}", "base64": "{{ $binary.data.data }}" }] }
```

Feed `markdown` or `chunks[].text` into your LLM or vector store node. Make works the same way with the HTTP "Make a request" module.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `urls` | array of strings | — | Public URLs of documents (PDF, DOCX, XLSX, PPTX, CSV, TXT). Required unless `files` is provided. |
| `files` | array of `{fileName, base64}` | `[]` | Documents as Base64 or Data URI (`data:application/pdf;base64,...`), max 6.5 MB per decoded file, the whole input must stay under 9 MB. Required unless `urls` is provided. |
| `outputFormat` | `markdown` | `text` | `markdown` | Markdown keeps headings, lists and tables; `text` returns plain text. |
| `includeTables` | boolean | `true` | Extract tables as Markdown and as JSON rows. |
| `pageRange` | string | `""` | Pages for PDF and PPTX, e.g. `1-5,8` or `10-`. Empty = all pages. |
| `chunkSize` | integer | `0` | Chunk size in characters for RAG, e.g. `2000`. `0` = no chunking. |
| `chunkOverlap` | integer | `200` | Overlap between chunks in characters, capped at half of `chunkSize`. |
| `maxPages` | integer | `300` | Safety limit of pages per document. Pages over the limit are skipped and not charged. |
| `ocr` | boolean | `false` | Run OCR on scanned PDF pages without a text layer and on PNG, JPEG, TIFF and WEBP images. Charged per OCR page. |
| `ocrLanguages` | array | `["eng"]` | OCR languages: `eng`, `deu`, `fra`, `spa`, `ita`, `por`, `nld`, `pol`, `rus`, `ukr`, `tur`, `ces`, `chi_sim`, `jpn`. Fewer languages is faster. |

```json
{
  "urls": ["https://arxiv.org/pdf/1706.03762", "https://docs.sheetjs.com/pres.xlsx"],
  "files": [],
  "outputFormat": "markdown",
  "includeTables": true,
  "chunkSize": 2000,
  "chunkOverlap": 200
}
```

### Output

One dataset item per document. Every field is always present (`null` or `[]` when there is no data).

```json
{
  "sourceType": "url",
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileName": "1706.03762v7.pdf",
  "success": true,
  "fileType": "pdf",
  "title": "Attention Is All You Need",
  "pageCount": 15,
  "pagesProcessed": 15,
  "markdown": "# Attention Is All You Need\n\n## Abstract\n\nThe dominant sequence transduction models ...",
  "tables": [
    {
      "page": 8,
      "sheet": null,
      "markdown": "| Model | BLEU EN-DE | EN-FR | Training Cost (FLOPs) EN-DE | EN-FR |\n|---|---|---|---|---|\n...",
      "rows": [["Model", "BLEU EN-DE", "EN-FR", "Training Cost (FLOPs) EN-DE", "EN-FR"], ["GNMT + RL [38]", "24.6", "39.92", "2.3 · 10^19", "1.4 · 10^20"]]
    }
  ],
  "chunks": [{ "index": 0, "text": "# Attention Is All You Need ...", "pageStart": 1, "pageEnd": 2 }],
  "metadata": { "author": null, "createdAt": "2024-04-10T21:11:43Z", "language": null },
  "charCount": 40868,
  "needsOcr": false,
  "ocrPages": 0,
  "fullTextUrl": null,
  "fullResultUrl": null,
  "error": null
}
```

- `sourceType` is `url`, `upload` (a public Apify key-value store record URL) or `base64`; for Base64 input `url` is `null`.
- `tables[].page` is the page number for PDF and PPTX; `tables[].sheet` is the worksheet name for XLSX.
- `chunks[].pageStart` and `pageEnd` let you cite the page of every chunk.
- `ocrPages` is the number of pages or images converted with OCR; `needsOcr: true` means some pages had no text layer and `ocr` was off.
- A failed document has `success: false` and a readable `error`, for example `URL returned an HTML page instead of a document`.
- If the Markdown is larger than 5 MB, the full text is saved to the run's key-value store (`fullTextUrl`) and `markdown` holds the first 100,000 characters.

### How much does it cost to convert PDF to Markdown?

The Actor uses pay-per-event pricing. You pay only for documents that were converted successfully.

| Event | Free | Bronze | Silver | Gold+ |
|---|---|---|---|---|
| Actor start (per run) | $0.00005 | $0.00005 | $0.00005 | $0.00005 |
| Document converted (first 20 pages included) | $0.003 | $0.0025 | $0.002 | $0.0015 |
| Extra page (each page over 20) | $0.0001 | $0.00008 | $0.00006 | $0.00005 |
| OCR page (each scanned page or image processed with OCR) | $0.002 | $0.0018 | $0.0015 | $0.0012 |

A page for non-PDF documents: DOCX and TXT — every 3,000 characters, XLSX and CSV — every 100 rows, PPTX — one slide.

Examples on the Free plan, all documents in one run:

- 100 documents of 10 pages: $0.00005 + 100 × $0.003 ≈ **$0.30**.
- 1,000 documents of 10 pages: $0.00005 + 1,000 × $0.003 ≈ **$3.00**.
- 1,000 documents of 100 pages: $0.00005 + 1,000 × ($0.003 + 80 × $0.0001) ≈ **$11.00**.
- 100 scanned documents of 5 pages with OCR: $0.00005 + 100 × ($0.003 + 5 × $0.002) ≈ **$1.30**. OCR pages are not counted as extra pages.

Failed downloads, HTML pages, scans when OCR is off, password-protected and corrupted files are not charged. Pages with a text layer are never charged as OCR pages. The run stops cleanly when your maximum charge per run is reached.

### FAQ

#### Does it support scanned PDFs and OCR?

Yes, with `"ocr": true`. OCR (Tesseract) runs only on PDF pages without a text layer and on PNG, JPEG, TIFF and WEBP images; pages with text use the fast text path. Set `ocrLanguages` for non-English documents, for example `["deu"]`. Each OCR page is charged with the `ocr-page` event, and runs with OCR get more memory automatically. With `ocr` off (the default), a scan is returned with `needsOcr: true` and `success: false`, and it is not charged. OCR output is plain paragraphs: tables on scanned pages are returned as text.

#### What are the file size limits?

Up to 50 MB per document from a URL and up to 6.5 MB per decoded Base64 file. The Apify API limits the whole run input to 9 MB, and Base64 adds about a third to the size, so all Base64 files in one run must total less than about 6.5 MB. Use URL input for larger files. `maxPages` (default 300) limits pages per document.

#### Can it open password-protected files?

No. Password-protected PDFs and Office files, and URLs that require a login, return an error and are not charged.

#### How well are complex tables extracted?

PDF tables drawn with ruling lines, as in most reports and scientific papers, are detected, including tables with horizontal rules only and multi-level headers. Merged cells are placed in the leftmost column they span. Tables laid out with whitespace only are returned as text. Word, Excel and PowerPoint tables are always extracted exactly.

#### Which formats are supported?

PDF, DOCX, XLSX (all sheets), PPTX (slides, tables and speaker notes), CSV and TXT/Markdown, plus PNG, JPEG, TIFF and WEBP images with OCR. Legacy `.doc`, `.xls`, `.ppt` and OpenDocument files are not supported; save them as DOCX, XLSX, PPTX or PDF.

#### Can I convert thousands of documents?

Yes. Pass all URLs in one `urls` array: one run processes them five at a time and is charged one start fee. For example, 1,000 documents of 10 pages in a single run cost about $3.00 on the Free plan. For recurring jobs, call the Actor from Make or n8n, or use Apify Schedules.

#### Is my data sent to an AI model or a third party?

No. The Actor does not call any external API or AI model. It downloads each document from the URL you provide and converts it inside your run with open-source parsers. Downloaded files are deleted right after conversion. The results are stored only in your run's dataset and key-value store in your Apify account, and they are kept for the data retention period of your Apify plan.

#### How does the price compare?

The run start costs $0.00005, while many document converters in Apify Store charge $0.001–$0.005 per run start. Failed documents, HTML pages and scans with OCR off are free. A run that converts one 10-page document costs about $0.003 in total, including the run start.

#### How is it different from other PDF text extractors?

One tool handles PDF and Office documents, returns tables as JSON, builds RAG chunks with page numbers and does not charge for failed documents.

### Other tools from mcpkit

- [Website Tech Stack Detector & Technology Lookup](https://apify.com/mcpkit/tech-stack-detector): find the CMS, frameworks, analytics and ad pixels of any website, plus the company's email provider and SaaS tools from DNS. Bulk domains for lead enrichment, $0.002 per domain.
- [Merge, Dedupe & Transform Datasets](https://apify.com/mcpkit/merge-dedup-datasets): merge Apify datasets and CSV, JSON or Excel files, remove duplicates, filter rows and export clean CSV or XLSX, no code. $0.05 per 1,000 rows.

# Changelog

This Actor's version history is a separate document: https://apify.com/mcpkit/pdf-to-markdown/changelog.md

# Actor input Schema

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

Public URLs of documents (PDF, DOCX, XLSX, PPTX, CSV, TXT, or PNG/JPEG/TIFF/WEBP images with ocr). The file type is detected from the file content. Required unless files is provided. Example: \["https://arxiv.org/pdf/1706.03762"]

## `files` (type: `array`):

Documents passed inline as Base64 or Data URI, for n8n, Make and API pipelines. Each item is an object with fileName and base64; fileName helps detect the format. Max 6.5 MB per decoded file; the whole input must stay under the 9 MB Apify input limit. Required unless urls is provided. Example: \[{"fileName": "report.pdf", "base64": "JVBERi0xLjcK..."}]

## `outputFormat` (type: `string`):

Output text format: markdown keeps headings, lists and tables; text returns plain text. Example: "markdown"

## `includeTables` (type: `boolean`):

Extract tables as Markdown inside the document and as JSON rows in the tables field. Example: true

## `ocr` (type: `boolean`):

Run OCR on scanned PDF pages without a text layer and on PNG, JPEG, TIFF and WEBP images. Pages with text still use the fast text path. Charged per OCR page. Example: true

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

Languages of the scanned text, used only when ocr is true. Pick one or more; fewer languages is faster. Example: \["eng", "deu"]

## `pageRange` (type: `string`):

Pages to process for PDF, PPTX (one slide = one page) and multi-page TIFF. Empty = all pages. Example: "1-5,8" or "10-" (page 10 to the end).

## `chunkSize` (type: `integer`):

Split the document text into chunks of about N characters for RAG. 0 = no chunking. Example: 2000

## `chunkOverlap` (type: `integer`):

Overlap between consecutive chunks in characters, capped at half of chunkSize. Example: 200

## `maxPages` (type: `integer`):

Safety limit of pages per document. Pages over the limit are skipped and not charged. Example: 300

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://docs.sheetjs.com/pres.xlsx"
  ],
  "files": [],
  "outputFormat": "markdown",
  "includeTables": true,
  "ocr": false,
  "ocrLanguages": [
    "eng"
  ],
  "pageRange": "",
  "chunkSize": 0,
  "chunkOverlap": 200,
  "maxPages": 300
}
```

# Actor output Schema

## `documents` (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",
        "https://docs.sheetjs.com/pres.xlsx"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mcpkit/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",
        "https://docs.sheetjs.com/pres.xlsx",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("mcpkit/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",
    "https://docs.sheetjs.com/pres.xlsx"
  ]
}' |
apify call mcpkit/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mcpkit/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/YkcgkX0RWiW42v9gA/builds/57FNEMB8wdrfs3Vnh/openapi.json
