# PDF to Markdown, Tables and Chunks for AI (`alvin_tom/pdf-to-markdown-tables`) Actor

Turn PDF URLs into clean Markdown, structured tables (rows as JSON) and RAG-ready chunks. Built for AI agents and LLM pipelines: one call, clean JSON, pay per page.

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

## Pricing

from $3.00 / 1,000 pdf documents

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, Tables and Chunks for AI

Give it PDF links, get back **clean Markdown**, **tables as rows** and **RAG-ready chunks** in one call. Made for AI agents, LLM pipelines and anyone who needs the text and tables out of PDFs, not just raw text.

### What you get per PDF

- `markdown`: the whole document as Markdown, with `<!-- page N -->` markers and tables as Markdown tables
- `tables`: every table found, as `{page, index, rows}` (rows are lists of cells)
- `chunks`: pieces of about `chunkSize` characters with `page` and `pageEnd`, ready for embeddings
- `scannedPages`: pages with no text layer (scans)
- `ocrPages`: scanned pages that were read with OCR (18 languages incl. Malay, Chinese, Arabic)
- `pageCount`, `pagesRead`, `title`, `error`

### Input

```json
{ "pdfUrls": ["https://arxiv.org/pdf/1706.03762"], "includeTables": true, "chunkSize": 1500, "chunkOverlap": 150, "maxPages": 200 }
```

### Pricing

Pay per PDF plus per page: one `document` event for each PDF read, and one `pdf-page` event for each page read, and one `ocr-page` event for each scanned page read with OCR. You are never charged for pages past `maxPages` or for PDFs that fail, and the run stops cleanly when your spending limit is reached.

### Use cases

- Load reports, contracts, papers and manuals into a RAG pipeline or vector database
- Let an AI agent read a PDF link in the middle of a task
- Pull tables (price lists, specs, financials) out as rows for a spreadsheet or database
- Read scanned letters, invoices and forms in Malay, Chinese, English and 15 more languages

### Output example

```json
{
  "itemType": "document",
  "url": "https://arxiv.org/pdf/1706.03762",
  "pageCount": 15, "pagesRead": 15, "scannedPages": [],
  "tableCount": 2, "chunkCount": 35, "error": null,
  "markdown": "<!-- page 1 -->\n...",
  "tables": [{ "page": 9, "index": 0, "rows": [["N", "d model"], ["6", "512"]] }],
  "chunks": [{ "index": 0, "page": 1, "pageEnd": 1, "chars": 1500, "text": "<!-- page 1 -->\n..." }],
  "bigFile": false
}
```

### Price examples

| What you read | You pay |
|---|---|
| 1 PDF, 10 pages | $0.004 |
| 1 PDF, 100 pages | $0.013 |
| 1,000 PDFs of 20 pages | about $5 |

Plus a tiny start fee ($0.00005) per run. Scanned pages read with OCR: $0.004 per OCR page (you can turn OCR off with `ocrScannedPages: false`, or cap it with `maxOcrPagesPerPdf`).

### Use it from code or an AI agent

Python (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("alvin_tom/pdf-to-markdown-tables").call(run_input={"pdfUrls": ["https://arxiv.org/pdf/1706.03762"]})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["url"], item.get("pageCount"), len(item.get("chunks") or []))
```

AI agents: add this Actor as a tool in Claude, Cursor or any MCP client through Apify's MCP server (`https://mcp.apify.com/?tools=alvin_tom/pdf-to-markdown-tables`). The agent passes links and gets clean JSON back.

### FAQ

**Does it read scanned PDFs?** Yes. Pages with no text layer are read with OCR (set `ocrLanguages`, e.g. `["eng", "msa"]`) and listed in `ocrPages`.

**Password-protected PDFs?** Not supported yet. You get an `error` and no charge.

**Can I send a file instead of a link?** Give any public link, for example a file in an Apify key-value store or cloud storage.

### Good to know

- Scanned pages are read with OCR in the languages you pick. Clean scans read best; handwriting is not supported.
- Tables drawn with lines or with clear column alignment are found; tables with no lines and loose spacing may be missed.
- Limits: 60 MB per PDF, public http(s) links only. Every redirect is checked too, so links can't lead to private or local addresses.
- We don't keep your files: each PDF is read in memory and only the result goes to your dataset. Author and other metadata are not returned.

Support: open an issue on this Actor. Replies come from an AI assistant and are checked by our rules.

### Large documents

Results up to about 8 MB come back as one dataset item. Bigger ones switch to big-file mode on their own: the full Markdown (and tables) are saved in the run's key-value store, the document item gives `markdownKey`/`markdownUrl`, and each chunk becomes its own dataset item (`itemType: "chunk"`). Filter on `itemType` to tell them apart.

# Actor input Schema

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

Public http(s) links to PDF files. One output item per PDF.

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

Return tables as rows (JSON) and as Markdown tables inside the text.

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

Split the Markdown into chunks of about this many characters for RAG. 0 turns chunking off.

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

Characters repeated between neighbouring chunks.

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

Stop after this many pages (you are charged only for pages read).

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

Pages with no text layer (scans, photos) are read with OCR and charged per OCR page. Turn off to only list them in scannedPages.

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

Languages on the scanned pages. Pick only what you need: each extra language makes OCR slower.

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

Upper limit on scanned pages read with OCR in each PDF (cost control).

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "includeTables": true,
  "chunkSize": 1500,
  "chunkOverlap": 150,
  "maxPages": 200,
  "ocrScannedPages": true,
  "ocrLanguages": [
    "eng"
  ],
  "maxOcrPagesPerPdf": 50
}
```

# Actor output Schema

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

One item per file, with the text and an error field if it failed

## `bigFiles` (type: `string`):

Markdown and tables of very large files

# 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": [
        "https://arxiv.org/pdf/1706.03762"
    ]
};

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

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

```

## MCP server setup

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

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/jHsVQnbTudXJSdV6c/builds/va42ascQAF1YjPuNN/openapi.json
