# PDF to Markdown — Tables + OCR, for RAG & AI Agents (`lizaraco/pdf-to-markdown`) Actor

Convert PDFs to clean markdown at scale: layout-aware text extraction, table handling, and a vision-model OCR tier for scanned or broken pages. Per-page transparency, never-fail runs.

- **URL**: https://apify.com/lizaraco/pdf-to-markdown.md
- **Developed by:** [Shawn Downs](https://apify.com/lizaraco) (community)
- **Categories:** AI, Automation, Agents
- **Stats:** 1 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 page converteds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF to Markdown — Tables + OCR, for RAG & AI Agents

Convert PDFs into clean, LLM-ready markdown at scale. Every page is quality-scored and
routed to the right engine: fast layout-aware extraction for born-digital pages, and a
**vision-model OCR tier** for scanned, broken, or table-dense pages — so one bad scan
doesn't wreck your pipeline, and you don't pay OCR prices for clean pages.

Unofficial independent tool. Your documents are processed only to produce your output.

### Convert PDFs to markdown for RAG

Feed a list of PDF URLs, get markdown with headings, lists, and tables preserved. Use
`perPageRows: true` to receive one row per page — ready for chunking into a vector store.
Each page reports its extraction `method` (`text` or `vlm`) and quality signals
(character count, garbage ratio, image coverage), so you always know what happened.

### OCR scanned PDFs with a vision model

Pages with no usable text layer — scans, faxes, image-only exports, PDFs with broken font
maps — are rendered and transcribed by a vision language model into proper markdown,
tables included. Three modes via `llmOcr`:

- `auto` (default): only pages that need it are billed as `ocr-page` events
- `off`: deterministic extraction only — **no LLM ever sees your document**
- `always`: force every page through the vision model for maximum fidelity

### Extract tables from PDF to markdown

Born-digital tables are extracted from the layout; ambiguous or scanned tables go through
the vision tier and come back as GitHub-flavored markdown tables instead of tab-soup.

### Never-fail runs

Corrupt files, password-protected PDFs, and dead URLs come back as structured error rows
(`{url, error}`) — the run itself succeeds, your pipeline keeps moving, and you only pay
for pages actually processed. User-set spending caps are respected mid-run: processing
stops cleanly at your limit with `charge_limit_reached: true` on the row.

### Output schema

Per document: `url, pages_processed, pages_total, ocr_pages, methods, vlm_usage,
markdown, char_count`. Per page (with `perPageRows`): `url, page, markdown, method,
chars, alpha_ratio, garbage, image_cover`.

### Use with AI agents

MCP-friendly: an agent can hand this actor a PDF URL and get structured markdown back in
one call, paying cents per document. Pairs naturally with web-crawling actors — crawl,
collect PDF links, convert here, feed your RAG store.

# Actor input Schema

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

Direct links to PDF (or DOCX-exported PDF) files to convert.

## `llmOcr` (type: `string`):

Pages routed to the vision model are billed as ocr-page events. 'off' guarantees no third-party LLM processing.

## `perPageRows` (type: `boolean`):

Instead of one row per document — handy for RAG chunking.

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

Pages beyond this are skipped (reported in the output row).

## `includePageImagesNote` (type: `boolean`):

Insert an \[image] placeholder where significant images appear.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "llmOcr": "auto",
  "perPageRows": false,
  "maxPages": 200,
  "includePageImagesNote": true
}
```

# 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("lizaraco/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("lizaraco/pdf-to-markdown").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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 lizaraco/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=lizaraco/pdf-to-markdown",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/KxexHdxsqgzRv9I4Y/builds/ncAefvSl7CVzG3EJ4/openapi.json
