# PDF to Markdown & Text Converter for LLMs and RAG (`rjmacarthy/pdf-to-markdown`) Actor

Convert PDFs (URLs or uploads) to clean Markdown or text for LLMs and RAG: headings, lists, tables, headers/footers and page numbers removed. One item per PDF, per page or RAG chunks with overlap. Pay per page; scans and failed files are free.

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

## Pricing

from $0.50 / 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/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 & Text Converter for LLMs and RAG

Turn any public PDF (or one you upload) into **clean, structured Markdown** or plain text that LLMs, vector databases and RAG pipelines can actually use. Most PDF extractors give you a wall of text with page headers, page numbers and broken words mixed in. This Actor rebuilds the document's structure: `#` headings from the font sizes and section numbers, bullet and numbered lists, simple tables, two-column reading order, words re-joined at line-break hyphens, running headers, footers and page numbers removed. Get **one item per PDF, one per page, or ready-to-embed chunks** with overlap, a heading path and page numbers. You pay **$0.50 per 1,000 converted pages**, and only for pages that actually had text: scanned pages, failed downloads and protected files cost nothing.

### What data can you get?

| Field | Example | Notes |
|---|---|---|
| `markdown` | `# Attention Is All You Need\n\n## Abstract\n\nThe dominant…` | Headings, lists, tables. `null` if you chose plain text only |
| `text` | `Abstract\n\nThe dominant…` | Plain text without markup (choose "Plain text" or "Both") |
| `type` | `document` / `page` / `chunk` / `error` | Depends on "One dataset item per" |
| `pageFrom`, `pageTo`, `pageNumber` | `1`, `15`, `null` | Page range of the item, for citations |
| `chunkIndex`, `chunkCount`, `headingPath` | `3`, `42`, `["3 Model Architecture", "3.1 Encoder and Decoder Stacks"]` | Chunk items: the section the chunk belongs to |
| `charCount`, `wordCount`, `tokenEstimate` | `40292`, `6060`, `10073` | Token estimate ≈ characters / 4 |
| `title` | `Attention Is All You Need` | PDF title, or the first top-level heading, or the file name |
| `isScanned`, `pagesWithoutText` | `false`, `[]` | Image-only pages are flagged and never charged |
| `metadata` | title, author, subject, keywords, creator, producer, creation/modification dates, page count, PDF version, encrypted flag, file size, SHA-256, language | From the PDF file itself |
| `warnings`, `error`, `errorCode` | `NOT_FOUND`, `NOT_PDF`, `PASSWORD_PROTECTED`, `TOO_LARGE`… | Problems are reported per file; the run carries on |
| `url`, `fileName`, `id`, `scrapedAt` | `https://arxiv.org/pdf/1706.03762`, `1706.03762v7.pdf` | `id` is stable: based on the file's SHA-256 |

### Use cases

- **RAG / chatbots over documents:** chunk reports, manuals, papers and policies into overlapping, heading-aware pieces with page numbers for citations, then load them into Pinecone, Qdrant, Weaviate, pgvector or any vector store.
- **LLM prompts:** give GPT, Claude or Gemini clean Markdown instead of raw PDF text: fewer tokens (no repeated headers, page numbers or dot leaders) and the structure stays intact.
- **Research and knowledge bases:** convert arXiv papers, government reports, annual reports and standards into Markdown for Obsidian, Notion or a docs site.
- **Document pipelines:** extract text plus metadata (author, dates, page count, SHA-256 for de-duplication) from batches of PDF links on a schedule.
- **Search indexing:** one item per page with its page number for page-level search results.

### How to use

1. Paste one or more PDF links into **PDF URLs** (or upload a file in **Or upload a PDF file**).
2. Choose **Output format** (Markdown, plain text or both) and **One dataset item per** (document, page or chunks).
3. Click **Start** and download the results as JSON, CSV, Excel or Markdown from the Output tab, or fetch them through the API.

Links to arXiv abstract pages, GitHub file pages, Dropbox and Google Drive share links are rewritten to the direct download automatically. The file must be publicly downloadable (no login).

#### Input examples

Whole document as Markdown (the default):

```json
{
    "urls": ["https://arxiv.org/pdf/1706.03762"],
    "outputFormat": "markdown",
    "granularity": "document",
    "maxPagesPerDocument": 20
}
```

RAG chunks of ~500 tokens with 50 tokens of overlap, in Markdown and plain text:

```json
{
    "urls": [
        "https://nvlpubs.nist.gov/nistpubs/CSWP/NIST.CSWP.29.pdf",
        "https://arxiv.org/abs/1512.03385"
    ],
    "granularity": "chunks",
    "chunkSize": 500,
    "chunkOverlap": 50,
    "outputFormat": "both"
}
```

One item per page, only pages 1-10 and 15:

```json
{
    "urls": ["https://example.com/annual-report.pdf"],
    "granularity": "page",
    "pageRange": "1-10, 15"
}
```

| Setting | Default | What it does |
|---|---|---|
| `urls` | – | PDF links, one per line |
| `uploadedFile` | – | A PDF you upload (or a link to one) |
| `outputFormat` | `markdown` | `markdown`, `text` or `both` |
| `granularity` | `document` | `document`, `page` or `chunks` |
| `chunkSize` / `chunkOverlap` | `500` / `50` | Approximate tokens (1 token ≈ 4 characters); chunks end at sentence, list-item or table-row boundaries and start fresh at headings |
| `includePageMarkers` | `false` | Adds `<!-- page N -->` where each page starts (document output; chunks and pages carry `pageFrom`/`pageTo`) |
| `pageRange` | all pages | e.g. `1-10, 15, 20-` |
| `maxPagesPerDocument` | `200` | 0 = no limit |
| `maxFileSizeMb` | `50` | Larger files become an error item (not charged) |
| `removeHeadersFooters` | `true` | Removes text repeated at the top/bottom of at least half the pages, and page numbers |
| `pdfPassword` | – | For your own password-protected PDFs |
| `maxConcurrency` | `3` | Parallel downloads (max 3 per website) |
| `proxyConfiguration` | off | Only needed if a website blocks downloads from Apify's servers. Apify datacenter proxy or your own proxy URLs; residential is not supported |

### Output example

A real result for `https://arxiv.org/pdf/1706.03762` (the Markdown is shortened here; the full item has all 15 pages, ~40,000 characters):

```json
{
    "id": "pdf:bdfaa68d8984f0dc:document",
    "type": "document",
    "url": "https://arxiv.org/pdf/1706.03762",
    "fileName": "1706.03762v7.pdf",
    "title": "Attention Is All You Need",
    "pageFrom": 1,
    "pageTo": 15,
    "markdown": "# Attention Is All You Need\n\n[…]\n\n## Abstract\n\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks …\n\n## 1 Introduction\n\n…\n\n### 3.1 Encoder and Decoder Stacks\n\n…",
    "text": null,
    "charCount": 40292,
    "wordCount": 6060,
    "tokenEstimate": 10073,
    "textPages": 15,
    "hasTextLayer": true,
    "isScanned": false,
    "pagesWithoutText": [],
    "metadata": {
        "title": null,
        "author": null,
        "creator": "LaTeX with hyperref",
        "producer": "pdfTeX-1.40.25",
        "creationDate": "2024-04-10T21:11:43.000Z",
        "modificationDate": "2024-04-10T21:11:43.000Z",
        "pageCount": 15,
        "pdfVersion": "1.5",
        "isEncrypted": false,
        "fileSizeBytes": 2215244,
        "sha256": "bdfaa68d8984f0dc02beaca527b76f207d99b666d31d1da728ee0728182df697",
        "language": "en",
        "languageSource": "detected"
    },
    "warnings": ["Skipped 966 characters of rotated or diagonal text (margin stamps, watermarks)."],
    "error": null,
    "errorCode": null,
    "scrapedAt": "2026-11-02T13:56:55.095Z"
}
```

A file that can't be converted gives an error item instead (free), and the other files are still converted:

```json
{
    "id": "error:405c6bb9bd24d428",
    "type": "error",
    "url": "https://nvlpubs.nist.gov/nistpubs/CSWP/NIST.CSWP.9999.pdf",
    "markdown": null,
    "error": "HTTP 404: the file was not found at this URL",
    "errorCode": "NOT_FOUND"
}
```

More examples (page items, error items) are in [`samples/sample-output.json`](samples/sample-output.json). A run summary with the status of every file is saved as `RUN_SUMMARY` in the run's key-value store.

### Pricing

Pay-per-event pricing, one event:

| Event | Price | When it is charged |
|---|---|---|
| `page` | **$0.0005** per page | Once per PDF page that was converted and had text |

That is **$0.50 per 1,000 pages**. Examples:

- A 15-page research paper: 15 × $0.0005 = **$0.0075**
- 100 annual reports of 80 pages: 8,000 pages = **$4.00**
- 1,000 pages chunked for RAG: **$0.50**, however many chunks they become

**You are not charged for:** pages without a text layer (scans, image-only or blank pages), files that fail (404, not a PDF, password-protected, too big, damaged), the same file given twice in one run, and pages outside your page range or page limit. Set "Maximum cost per run" in the run options to cap your spend: the Actor stops cleanly at the limit and tells you where.

### Tips and limits

- **No OCR (yet).** Scanned or image-only PDFs have no text to extract. They are detected (`isScanned: true`, `pagesWithoutText: [...]`), reported in `warnings`, and not charged. OCR is planned for a later version.
- **Tables are best-effort.** Simple grids (one line per row, clear column gaps) become Markdown tables. Tables with merged cells, multi-line cells or very tight columns may come out as text lines or a rough grid.
- **Math and figures.** Formulas come out as plain characters (no LaTeX), and images are not extracted. Labels inside vector charts can appear as short stray lines.
- **Layout.** One- and two-column layouts are handled; three or more columns, magazine layouts and text boxes may be read in the wrong order. Bold/italic inside paragraphs is not marked up.
- **Headers/footers** are detected when they repeat on at least half of the converted pages, so they need 3+ pages. Lone page numbers are always removed.
- **Rotated text** in margins (such as arXiv side stamps) and diagonal watermarks are skipped; landscape pages are read normally.
- **Downloads:** only public files. Pages that require a login, or Google Drive files too big for Google's virus scan, return a web page instead of the PDF: you get a clear `NOT_PDF` error. Use a direct link or upload the file.
- **Big files:** the default limit is 50 MB per file (max 500 MB). For files over 100 MB, give the run 1,024 MB or more memory.
- **Speed:** a 15-page paper converts in about one second after download.

### FAQ

**How is a page counted?** One `page` event per PDF page that was converted and contained text. A 20-page PDF with a 5-page range is 5 pages. Scanned pages inside a mixed PDF are skipped and free.

**Can it read scanned documents?** Not in this version: it reads the PDF's text layer. Scanned pages are flagged so you can send them to an OCR tool, and you don't pay for them.

**Which languages work?** Any language whose PDF has a proper text layer, including accented Latin scripts, Cyrillic, Greek, Chinese, Japanese and Korean (CJK lines are joined without extra spaces). Right-to-left scripts (Arabic, Hebrew) are extracted, but words may come out in reversed order. The `metadata.language` field gives the PDF's declared language or a detected one.

**What chunk size should I use?** 300-800 tokens with 10-15% overlap works well for most embedding models. Each chunk carries `headingPath` and `pageFrom`/`pageTo`, so you can show "Section 3.1, page 4" next to an answer.

**Can I use residential proxies?** No. If you select a residential (or SERP) proxy group, the run logs a warning and uses Apify datacenter proxy instead. PDFs are large downloads (often 100-150 KB per page), and residential traffic would cost more than the per-page price, which would force a much higher price for everyone. Most PDF hosts (journals, arXiv, government and company sites) work without any proxy. If a site blocks Apify's servers, try datacenter proxy, add your own proxy URLs, or download the file and upload it in the input form.

**Can I convert my own files?** Yes: upload a PDF in the input form, or put it anywhere with a public link. Password-protected files you own can be opened with "PDF password".

**Is it legal?** The Actor only downloads files you point it to, the way a browser would, and converts them; it does not crawl or log in anywhere. Only process documents you have the right to use, respect copyright and the terms of the website you download from, and handle any personal data in the documents according to applicable laws (such as the GDPR). You are responsible for how you use the output.

### Integrations

- **API:** start runs and read results with the [Apify API](https://docs.apify.com/api/v2) or the JavaScript/Python clients; get the dataset in JSON, CSV, Excel or XML.
- **Make, Zapier and n8n:** use the Apify app/node to convert PDFs from a form, an email attachment link or a spreadsheet of URLs, and send the Markdown on to Notion, Google Docs or your LLM step.
- **LangChain and LlamaIndex:** load the dataset with the Apify dataset loader and map `markdown` (or `text`) to the document content and the other fields to metadata.
- **MCP:** AI agents can call this Actor as a tool through the [Apify MCP server](https://mcp.apify.com) to read PDFs on demand.
- **Webhooks and schedules:** run it on a schedule and get notified when results are ready.

### Changelog

- **0.1 (November 2026):** First release. Markdown and plain text, document/page/chunk output, headings from font size, weight and section numbers, lists, simple tables, two-column reading order, header/footer and page-number removal, de-hyphenation, PDF metadata and language, scanned-page detection, uploads, page ranges and password-protected files.

### More scrapers by the same developer

- [Telegram Channel Scraper](https://apify.com/rjmacarthy/telegram-channel-scraper)
- [ATS Jobs Scraper: Greenhouse, Lever, Ashby & Workday](https://apify.com/rjmacarthy/ats-jobs-scraper)
- [Workday Jobs Scraper](https://apify.com/rjmacarthy/workday-jobs-scraper)
- [AI Visibility Tracker: ChatGPT, Perplexity, Gemini, Claude](https://apify.com/rjmacarthy/ai-search-visibility-tracker)
- [Google Ads Transparency Scraper](https://apify.com/rjmacarthy/google-ads-transparency-scraper)
- [Substack Scraper](https://apify.com/rjmacarthy/substack-scraper)

Browse all my Actors on [my Apify Store profile](https://apify.com/rjmacarthy).

# Actor input Schema

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

Direct links to PDF files, one per line, e.g. https://arxiv.org/pdf/1706.03762. arXiv abstract pages, GitHub file pages, Dropbox and Google Drive share links are rewritten to their download URL automatically. The file must be public (no login).

## `uploadedFile` (type: `string`):

Upload a PDF from your computer (stored in a key-value store) or paste a link to one. Converted together with the URLs above.

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

Markdown keeps structure (# headings, - lists, | tables |) and is the best input for LLMs. Plain text has no markup. "Both" fills both fields.

## `granularity` (type: `string`):

Document: the whole PDF in one item. Page: one item per page (with its page number, good for citations). Chunks: fixed-size, overlapping pieces with their heading path and page range, ready for embeddings / RAG.

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

Target chunk size when "One dataset item per" is Chunks, in approximate LLM tokens (1 token ≈ 4 characters of English). Chunks end at sentence, list-item or table-row boundaries and start fresh at headings when possible.

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

How much text each chunk repeats from the end of the previous one (whole sentences, never across a heading). At most half the chunk size.

## `includePageMarkers` (type: `boolean`):

In Document output, insert  (Markdown) or --- Page N --- (text) where each page starts, so you can cite page numbers. (Chunk and page items carry pageFrom/pageTo instead.)

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

Only convert these pages of every PDF, e.g. "1-10, 15, 20-" ("20-" = page 20 to the end). Leave empty for all pages.

## `maxPagesPerDocument` (type: `integer`):

Convert at most this many pages of each PDF (after the page range). 0 = no limit.

## `maxFileSizeMb` (type: `integer`):

Skip PDFs larger than this (reported as an error item, not charged). Very large files need more memory: use 1024 MB+ memory for files over 100 MB.

## `removeHeadersFooters` (type: `boolean`):

Drop text that repeats at the top or bottom of at least half of the pages (needs 3+ pages) and lone page numbers. Recommended for LLM / RAG use.

## `pdfPassword` (type: `string`):

Only for your own password-protected PDFs: the password to open them (used for every file in this run). Without it, protected files are reported as errors and not charged.

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

How many PDFs are downloaded at the same time (at most 3 from one website). Conversion itself runs one PDF at a time.

## `proxyConfiguration` (type: `object`):

Not needed for most PDFs. Enable Apify Proxy (datacenter) if a website blocks downloads from Apify's servers (HTTP 403/429), or add your own proxy URLs. Residential and SERP proxy groups are not supported: the run falls back to Apify datacenter proxy.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "outputFormat": "markdown",
  "granularity": "document",
  "chunkSize": 500,
  "chunkOverlap": 50,
  "includePageMarkers": false,
  "maxPagesPerDocument": 20,
  "maxFileSizeMb": 50,
  "removeHeadersFooters": true,
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

One row per document, page or chunk: title, page range, word and token counts, scanned flag and errors.

## `content` (type: `string`):

The converted content with page ranges and section headings.

## `items` (type: `string`):

Every field of every item, including PDF metadata and warnings.

## `summary` (type: `string`):

Per-PDF status, pages converted and charged, pages without text, errors and request statistics.

# 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"
    ],
    "maxPagesPerDocument": 20
};

// Run the Actor and wait for it to finish
const run = await client.actor("rjmacarthy/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"],
    "maxPagesPerDocument": 20,
}

# Run the Actor and wait for it to finish
run = client.actor("rjmacarthy/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"
  ],
  "maxPagesPerDocument": 20
}' |
apify call rjmacarthy/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

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