# PDF to Markdown for LLM & RAG (Tables + OCR) (`extas_corp/pdf-to-markdown`) Actor

Convert PDF to Markdown for LLM and RAG pipelines. Keeps headings, tables and reading order, and runs OCR on scanned PDFs. Bulk by URL, pay only for PDFs that convert.

- **URL**: https://apify.com/extas_corp/pdf-to-markdown.md
- **Developed by:** [Extas Corp](https://apify.com/extas_corp) (community)
- **Categories:** AI, Developer tools, Integrations
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-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 LLM & RAG (Tables + OCR)

Convert PDF files to **clean, LLM-ready Markdown**: headings, paragraphs, Markdown tables, and OCR for scanned pages. Built for **RAG pipelines, AI agents, document search and data extraction**.

- **Two-column papers read in the right order** (left column, then right)
- **Headings detected** from font sizes (`#`, `##`, `###`), paragraphs re-joined, hyphenated words fixed
- **Tables** converted to real Markdown tables (layout boxes are ignored)
- **Scanned PDFs**: pages without a text layer are OCR'd with Tesseract (English, French, German, Spanish, Italian, Portuguese, Dutch)
- **Bulk**: give hundreds of URLs, they're processed in parallel
- **Fair pricing**: you pay only for PDFs that convert successfully. Failed downloads cost nothing.

### How to use

1. Paste one or more direct PDF links into **PDF URLs** (or upload a text file with one URL per line).
2. Keep the defaults, or turn off OCR / tables, limit pages, pick the OCR language.
3. Click **Start**. Each PDF becomes one dataset item. Export as JSON, CSV, Excel, or fetch through the API.

### Input example

```json
{
  "pdfUrls": [{ "url": "https://arxiv.org/pdf/1706.03762" }],
  "extractTables": true,
  "ocrScannedPages": true,
  "ocrLanguage": "eng",
  "maxPages": 0
}
```

### Output example

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "ok",
  "title": "Attention Is All You Need",
  "pageCount": 15,
  "ocrPages": 0,
  "tableCount": 0,
  "charCount": 40211,
  "markdown": "# Attention Is All You Need\n\nAshish Vaswani ...\n\n### Abstract\n\nThe dominant sequence transduction models ..."
}
```

Failed PDFs come back with `"status": "error"` and an `error` message (not charged).

### Pricing

Pay per event:

| Event | Price |
| --- | --- |
| PDF converted (text layer) | $0.003 per PDF |
| OCR page (scanned page) | $0.01 per page |

1,000 text PDFs cost $3. Set a maximum cost per run in the run options and the Actor stops cleanly when it is reached.

### Use with AI agents and APIs

Call it from the Apify API, Python/JS clients, Make, Zapier, n8n, LangChain, LlamaIndex, or through the Apify MCP server, so your agent can read any PDF by URL.

```bash
curl -X POST "https://api.apify.com/v2/acts/<ACTOR_ID>/run-sync-get-dataset-items?token=<TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"pdfUrls":[{"url":"https://arxiv.org/pdf/1706.03762"}]}'
```

### Limits

- Max 100 MB per PDF, 5 minutes per PDF.
- Password-protected PDFs aren't supported.
- Complex multi-level tables (e.g. tax tables with merged cells) may come out simplified. Tables drawn without lines are kept as text.
- Two-column layouts (papers, journals) are detected and read column by column; full-width titles and figures stay in place.

### FAQ

**Is my data stored?** Only in your own Apify run storage, which follows your retention settings.

**Can I convert local files?** Upload them to any public URL (or Apify key-value store) and pass the link.

Found a PDF that converts badly? Open an issue on the Actor's Issues tab with the link and it will be fixed.

### Related Actors

- [Bulk Image OCR](https://apify.com/extas_corp/image-ocr): text from screenshots, scans and photos
- [Word, PowerPoint & Excel to Markdown](https://apify.com/extas_corp/document-to-markdown): DOCX, PPTX, XLSX, HTML, EPUB to Markdown

### Free browser version

Converting just one file? Use the free in-browser converter at [hackthehydra.com](https://hackthehydra.com): no upload, no account.

### More ways to use it

- **REST API without an Apify account:** the same converters are available on RapidAPI as the [Document to Markdown API](https://rapidapi.com/ExtasCorporation/api/document-to-markdown) (PDF, DOCX, PPTX, XLSX, images; free plan included).
- **Free in your browser:** [hackthehydra.com](https://hackthehydra.com) has no-upload converters for PDF, Word, Excel, PowerPoint and images.

### Use cases

- **LLM and RAG**: turn papers, manuals and reports into Markdown chunks for vector stores, with headings and tables preserved.
- **Research**: bulk-convert arXiv or publisher PDFs into searchable text for literature reviews.
- **Operations and SEO**: extract text from supplier catalogues, whitepapers and scanned contracts (OCR).

### Integrations

Python (Apify client):

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("extas_corp/pdf-to-markdown").call(run_input={"pdfUrls": [{"url": "https://arxiv.org/pdf/1706.03762"}]})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["markdown"][:500])
```

**LangChain / RAG** (turn each result into a `Document`):

```python
from apify_client import ApifyClient
from langchain_core.documents import Document

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("extas_corp/pdf-to-markdown").call(run_input={"pdfUrls": [{"url": "https://arxiv.org/pdf/1706.03762"}]})
docs = [Document(page_content=i["markdown"], metadata={"source": i.get("url")})
        for i in client.dataset(run["defaultDatasetId"]).iterate_items() if i.get("markdown")]
```

**Make, Zapier, n8n**: add the Apify app, choose *Run Actor* (or *Run Actor and get dataset items*), set the Actor to `extas_corp/pdf-to-markdown` and map the JSON input. The same Actor can be started on a schedule from Apify itself, with a webhook to your own endpoint when the run finishes.

# Actor input Schema

## `pdfUrls` (type: `array`):

Direct links to PDF files. Each PDF becomes one dataset item with its Markdown.

## `extractTables` (type: `boolean`):

Detect ruled tables and output them as Markdown tables instead of loose text.

## `ocrScannedPages` (type: `boolean`):

Run OCR (Tesseract) on pages that have no text layer, such as scans. Charged per OCR page.

## `ocrLanguage` (type: `string`):

Tesseract language code(s), e.g. eng, fra, deu, spa, ita, por, nld, or several joined with + (eng+fra).

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

Only convert the first N pages of each PDF. 0 = all pages.

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

How many PDFs to download and convert in parallel.

## Actor input object example

```json
{
  "pdfUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "extractTables": true,
  "ocrScannedPages": true,
  "ocrLanguage": "eng",
  "maxPages": 0,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `results` (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 = {
    "pdfUrls": [
        {
            "url": "https://arxiv.org/pdf/1706.03762"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("extas_corp/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 = { "pdfUrls": [{ "url": "https://arxiv.org/pdf/1706.03762" }] }

# Run the Actor and wait for it to finish
run = client.actor("extas_corp/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 '{
  "pdfUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ]
}' |
apify call extas_corp/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

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