# PDF to Markdown + tables for LLM and RAG (`supes/pdf-to-markdown`) Actor

Convert PDF URLs to page-marked Markdown, CSV tables, and token chunks for LLM and RAG workflows. Optional auto OCR on pages without a text layer. $0.004 per processed PDF, $0.002 per OCR page, $0.001 per table. Invalid and failed files are not charged.

- **URL**: https://apify.com/supes/pdf-to-markdown.md
- **Developed by:** [Supes Dad](https://apify.com/supes) (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 $4.00 / 1,000 pdf processeds

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 to CSV

**Turn PDF URLs into Markdown for LLM and RAG workflows.** The Actor downloads only the HTTP(S) links you supply, rebuilds page-marked Markdown with heading detection, extracts tables as inline Markdown and CSV, and optionally runs OCR on pages with no text layer. It does not crawl, follow redirects, or fetch links found inside a document.

- Actor: `supes/pdf-to-markdown`
- Console: https://console.apify.com/actors/BWKEWBQxb6lwNBXmZ

### What it does

For each PDF URL you provide, the Actor writes one dataset row:

- Downloads the file (50 MB limit, checked from `Content-Length` and again while streaming)
- Reconstructs Markdown with `<!-- page N -->` markers, headings from font size and bold weight, and tables inlined where they appear
- Saves accepted tables as CSV in the default key-value store, with row/column counts and a confidence of `high`, `medium`, or `low`
- Splits the Markdown into approximate token chunks (default 800) for embedding
- Runs Tesseract OCR when `ocr` is `auto` (pages with no text layer) or `force` (every selected page). The image includes English language data only

A bad URL or a failed file becomes an error row. The run continues with the rest of the list. Page-level failures are reported on the row while successful pages are kept.

### Who it's for

Use this Actor if you need to:

- Ingest research papers, manuals, contracts, or reports into a RAG or vector-search pipeline
- Give an agent or LLM a tool that turns a public PDF link into quoted, page-cited Markdown
- Extract ruled tables to CSV without standing up your own OCR or PDF stack
- Keep costs predictable: **$0.004 per processed PDF**, plus **$0.002 per OCR page** and **$0.001 per extracted table**

Typical use cases include RAG ingestion, document Q\&A, contract or report review, and knowledge-base indexing.

### What you get

Each input URL produces one dataset row, including error rows.

| Field | Type | Meaning |
| --- | --- | --- |
| `sourceUrl` | string | The input URL |
| `pageCount` | number | Pages in the PDF (0 on early failures) |
| `pagesProcessed` | number\[] | 1-based pages that were converted |
| `metadata` | object | `title`, `author`, and `created` when the PDF provides them |
| `markdown` | string | Page-marked Markdown, with tables inlined |
| `tables` | object\[] | Each entry has `page`, `index`, `rows`, `columns`, `csvKey`, `markdown`, and `confidence` |
| `tableCount` | number | Number of tables saved to the key-value store |
| `chunks` | object\[] | `{ text, pages, tokens }` slices of the Markdown |
| `ocrPages` | number\[] | Pages that were successfully OCR'd |
| `error` | object or `null` | `{ code, message }` when something failed; otherwise `null` |

CSV files are stored under `csvKey` in the default key-value store.

### Input

| Field | Required | Default | Description |
| --- | --- | --- | --- |
| `pdfUrls` | yes | — | Direct HTTP(S) PDF URLs. Credentials, fragments, redirects, and non-public IPs are rejected. |
| `pages` | no | all pages | Optional 1-based selection, for example `1-5,8` |
| `ocr` | no | `auto` | `auto` (only pages without text), `force` (all selected pages), or `off` |
| `ocrLanguages` | no | `eng` | Tesseract language codes. Only English data is installed in the image. |
| `extractTables` | no | `true` | Detect tables and save them as CSV |
| `chunkTokens` | no | `800` | Approximate maximum tokens per chunk (100–4000) |
| `maxConcurrency` | no | `2` | How many PDFs to process at once |

Example input:

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://example.com/notapdf"
  ],
  "ocr": "auto",
  "extractTables": true,
  "chunkTokens": 800,
  "maxConcurrency": 2
}
```

### Pricing

Pay per event. You pay the events below, not Apify platform usage.

| Event | Price | When it is charged |
| --- | --- | --- |
| `pdf-processed` | **$0.004** ($4 per 1,000) | After a successful or partially successful PDF row is saved |
| `page-ocr` | **$0.002** ($2 per 1,000) | Once per page that was successfully OCR'd |
| `table-extracted` | **$0.001** ($1 per 1,000) | Once per table saved to the key-value store |
| `apify-actor-start` | $0.00005 per start event | Charged automatically at the start of the run. At the default 1 GB memory, that is **$0.00005** |

Error rows are **not** charged: `INVALID_URL`, `DOWNLOAD_FAILED`, `TOO_LARGE`, `NOT_PDF`, and `ENCRYPTED`. There is no automatic per-dataset-row charge. If a run reaches your maximum spend, in-flight work is stopped and remaining URLs are skipped.

Worked examples (plus the $0.00005 start fee at 1 GB):

- 1 text-layer PDF, no tables: **$0.004**
- The sample 15-page paper (1 table, no OCR): **$0.005**
- 100 text-layer PDFs, no tables: **$0.40**
- 1 text-layer PDF with 4 saved tables: **$0.008**
- A 20-page scanned PDF (OCR on every page, no tables): **$0.044**
- 100 valid PDFs and 5 typo / failed downloads: **$0.40** (the failed rows are free)

### How to run

#### In Apify Console

1. Open [PDF to Markdown + Tables to CSV](https://console.apify.com/actors/BWKEWBQxb6lwNBXmZ).
2. Paste direct PDF URLs into **PDF URLs**. Leave **OCR** on **Only pages without text** unless you need to force OCR or turn it off.
3. Keep **Extract tables** checked and **Maximum concurrent PDFs** at `2` unless you have a reason to change them.
4. Run the Actor, then open the default dataset and key-value store when it finishes.

The input field titles above match this Actor's input schema.

#### From the API

Send the same JSON input to the Actor's run endpoint:

```bash
curl -X POST "https://api.apify.com/v2/acts/supes~pdf-to-markdown/runs?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pdfUrls":["https://arxiv.org/pdf/1706.03762"],"ocr":"auto","extractTables":true}'
```

You can also schedule the Actor or start it from an integration. Replace `YOUR_APIFY_TOKEN` with your own Apify API token.

### Sample output

The values below come from a successful row for `https://arxiv.org/pdf/1706.03762` in run `ZAHuoEBKbjPBbMkHE` on 10 November 2026 (America/New_York), build 1.0.2, with `ocr: auto` and `extractTables: true`. The live row had 15 pages processed, 42,015 characters of Markdown, 12 chunks, and one 8×9 table at medium confidence, saved as `pdf-1-p9-t1.csv`. The Markdown and table are trimmed here to keep the example short. The live `chunks` array had 12 items; only the first is shown, with its text shortened.

```json
{
  "sourceUrl": "https://arxiv.org/pdf/1706.03762",
  "pageCount": 15,
  "pagesProcessed": [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15],
  "metadata": { "title": null, "author": null, "created": "D:20240410211143Z" },
  "markdown": "<!-- page 1 -->\n\nProvided proper attribution is provided, Google hereby grants permission to\n\nreproduce the tables and figures in this paper solely for use in journalistic or\n\nscholarly works.\n\n# Attention Is All You Need\n\nAshish Vaswani ∗ Noam Shazeer ∗ Niki Parmar ∗ Jakob Uszkoreit ∗\n\n## Abstract\n\nThe dominant sequence transduction models are based on complex recurrent or\n\n…",
  "tables": [
    {
      "page": 9,
      "index": 1,
      "rows": 8,
      "columns": 9,
      "csvKey": "pdf-1-p9-t1.csv",
      "confidence": "medium",
      "markdown": "| N | d<br>model | d<br>ff | h | d<br>k | d P<br>v | drop | ϵ<br>ls | train<br>steps |\n| --- | --- | --- | --- | --- | --- | --- | --- | --- |\n| 6 | 512 | 2048 | 8 | 64 | 64 | 0.1 | 0.1 | 100K |\n…"
    }
  ],
  "tableCount": 1,
  "chunks": [
    { "text": "<!-- page 1 -->\n\nProvided proper attribution is provided, Google hereby grants permission to\n\n…", "pages": [1, 2, 3, 4, 5], "tokens": 800 }
  ],
  "ocrPages": [],
  "error": null
}
```

On the same run, `https://127.0.0.1/x.pdf` returned `error.code: INVALID_URL` (local addresses are blocked) and `https://example.com/notapdf` returned `DOWNLOAD_FAILED` with HTTP 404. Neither error row is charged.

### Limits

- 50 MB per PDF, checked from `Content-Length` and during the download.
- 500 pages per PDF, and 120 seconds of processing per PDF (30-second download timeout).
- Redirects are not followed. Use a direct link that returns HTTP 200 and a PDF body. The prefill `https://arxiv.org/pdf/1706.03762` works; a URL that 301s, including some `…/1706.03762.pdf` variants, will fail with `DOWNLOAD_FAILED`.
- Only `http` and `https` URLs are accepted. Loopback, private, link-local, and cloud-metadata addresses are rejected after DNS resolution, including IPv4-mapped IPv6.
- Default memory is 1024 MB. Default concurrency is 2, so results can arrive out of input order.
- Only English Tesseract data is included in the image. Other `ocrLanguages` values will fail unless you install those language packs yourself.

### Limitations

- Heading detection and layout reconstruction are heuristic. Complex multi-column pages, headers, and stamps can leave leftover characters in the Markdown.
- Unruled typographic tables (common in academic papers) usually come out as readable body text, not structured `tables[]` entries. Ruled tables can still have stacked or split cells; confidence may be `medium` or `low`.
- Attention or figure grids are filtered out and are not charged as tables, but leftover visualization glyphs can still appear in the body Markdown.
- Formulas, subscripts, and typographic math are lossy. They are linearized, not converted to LaTeX.
- OCR is best-effort. Auto OCR runs only when a page has no text layer, so a bad or garbage text layer will not trigger OCR. Headings on OCR pages can over-trigger (email lines or body sentences marked as headings).
- Metadata `title` and `author` are whatever the PDF stores. Many papers leave them empty.
- The Actor does not accept file uploads or base64, does not follow links inside PDFs, and cannot open password-protected files (`ENCRYPTED`).

### FAQ

**Do I need an API key?**
No. Only an Apify account. The Actor downloads public PDF URLs; it cannot open files behind a login.

**Are failed files charged?**
No. Invalid URLs, download failures, oversized files, non-PDFs, and encrypted files are not charged. A partially successful PDF (some pages converted, a page-level error on the same row) is charged `pdf-processed`, plus any OCR pages and saved tables.

**Will it OCR every page?**
Only if you set `ocr` to `force`. The default `auto` setting OCRs pages that have no text layer. Pages that already have text are left as text.

**Why wasn't my table extracted?**
Tables without ruling lines are often returned as text in `markdown` instead of a `tables[]` entry. That is expected. Figure-like grids are dropped on purpose so they are not billed.

**Why did a URL that works in my browser fail?**
The Actor does not follow redirects and does not send a browser profile. Use the final URL that returns HTTP 200 with a `%PDF-` header. Local and private addresses are blocked.

**Can I convert only some pages?**
Yes. Set `pages` to a 1-based range such as `1-5,8`.

**What language is OCR?**
English (`eng`) is installed. Other Tesseract codes can be requested in `ocrLanguages`, but those language packs are not in the image.

### Support

Found a bug or want a feature? Open an issue on this Actor's **Issues** tab in Apify Console. Include the run ID and the PDF URL that failed when you can.

# Actor input Schema

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

Direct HTTP(S) PDF URLs. Redirects and document links are not followed.

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

Optional 1-based page selection, e.g. 1-5,8. Leave empty for all pages.

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

Choose whether to use OCR on pages.

## `ocrLanguages` (type: `string`):

Tesseract language codes, e.g. eng. Other languages must be installed in the image.

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

Detect tables and save them as CSV.

## `chunkTokens` (type: `integer`):

Maximum approximate token count per chunk.

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

Maximum number of PDFs processed at once.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "ocr": "auto",
  "ocrLanguages": "eng",
  "extractTables": true,
  "chunkTokens": 800,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

One dataset row per PDF URL, including Markdown, tables, chunks, and any error.

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

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

```

## MCP server setup

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