# PDF to Text & Markdown Extractor (OCR, RAG Chunks, Metadata) (`richiedc95/pdf-text-extractor`) Actor

Convert PDF URLs to clean text or LLM-ready Markdown with headings, per-page text, RAG chunks and metadata. OCR for scanned pages in 100+ languages. $0.003 per PDF + $0.0001 per page; OCR $0.004 per page.

- **URL**: https://apify.com/richiedc95/pdf-text-extractor.md
- **Developed by:** [Richie Data](https://apify.com/richiedc95) (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

from $2.40 / 1,000 pdfs

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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 Text & Markdown Extractor (OCR, RAG Chunks, Metadata)

Turn **PDF files into clean text or LLM-ready Markdown** in seconds. Paste PDF URLs and get, for each file: the full text with headings and lists, optional **RAG chunks** for embeddings, optional text **per page** for citations, and the document **metadata** (title, author, creation date, page count).

⭐ **Is this Actor useful to you?** A short review on the Reviews tab helps other users find it, and tells us what to build next.

Built for AI pipelines, search indexes and data teams: no browser, no OCR guesswork on text PDFs, predictable pay-per-PDF pricing.

### Who uses it

- 🤖 **AI and RAG builders**: feed papers, manuals and contracts to ChatGPT, Claude or a vector database as clean Markdown chunks.
- 🔍 **Search and knowledge bases**: index reports, policies and documentation with titles, page numbers and metadata.
- ⚖️ **Legal, finance and research teams**: pull the text out of filings, contracts, invoices and academic papers for review or analysis.
- 🧾 **Scanned archives**: digitize scanned letters, forms and faxes with OCR in 100+ languages.
- 🔗 **Scraping pipelines**: extract the PDFs another scraper found (tender documents, annual reports, datasheets).

### What you get

- 📝 **Markdown with structure**: headings detected from font sizes (title, sections), bullet lists, paragraphs re-joined across lines and hyphenation. Running headers, footers and figure labels repeated on every page are removed.
- ✂️ **RAG chunks**: set a chunk size (e.g. 1,500 characters) and an overlap; chunks split on paragraph and sentence boundaries.
- 📄 **Text per page**: for answers that cite page numbers.
- 🏷️ **Metadata**: title, author, subject, keywords, creator/producer, created and modified dates, PDF version, page count, word count.
- 🔎 **OCR for scanned PDFs**: pages without a text layer (scans, photos, faxes) are read with Tesseract OCR in 100+ languages, automatically and only for those pages. Each OCR page reports its confidence.
- ⚡ **Fast**: a 15-page paper takes well under a second to extract. Up to 4 PDFs are processed in parallel.

### How to use it

1. Add one or more **PDF URLs** (direct links to the file).
2. Choose **Markdown** (best for LLMs) or **plain text**.
3. Optionally set a **chunk size** for RAG and turn on **text per page**.
4. Run it and download the results as JSON, CSV or Excel, or read them through the API.

#### Input fields

| Field | What it does | Default |
|---|---|---|
| `pdfUrls` | Direct links to the PDF files | required |
| `outputFormat` | `markdown` (headings, lists; best for LLMs) or `text` | `markdown` |
| `chunkSize` | Split the text into RAG chunks of this many characters (0 = off) | 0 |
| `chunkOverlap` | Characters repeated between consecutive chunks | 150 |
| `includePages` | Also return the text of each page, for citations | false |
| `maxPagesPerPdf` | Read only the first N pages (0 = all) | 0 |
| `maxFileSizeMb` | Skip files larger than this | 50 |
| `ocrMode` | `auto` (OCR only pages without text), `force` or `off` | `auto` |
| `ocrLanguages` | Tesseract languages, e.g. `eng`, `spa`, `eng+deu` | `eng` |
| `maxOcrPagesPerPdf` | Cap on OCR pages per file, to control cost | 50 |

#### Input example

```json
{
    "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
    "outputFormat": "markdown",
    "chunkSize": 1500,
    "includePages": false
}
```

### Output example

```json
{
    "url": "https://arxiv.org/pdf/1706.03762",
    "fileName": "1706.03762",
    "fileSizeBytes": 2215244,
    "pageCount": 15,
    "pagesProcessed": 15,
    "title": null,
    "author": null,
    "creator": "LaTeX with hyperref",
    "producer": "pdfTeX-1.40.25",
    "createdAt": "2024-04-10T21:11:43Z",
    "characters": 39010,
    "words": 6087,
    "pagesWithoutText": [],
    "needsOcr": false,
    "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...",
    "chunks": [
        {
            "index": 0,
            "text": "# Attention Is All You Need ...",
            "characters": 1480
        }
    ]
}
```

#### Output fields

| Field | Description |
|---|---|
| `url`, `fileName`, `fileSizeBytes` | Which file was read |
| `pageCount`, `pagesProcessed` | Pages in the file and pages extracted |
| `title`, `author`, `creator`, `producer`, `createdAt` | Document metadata (null when the PDF does not set it) |
| `characters`, `words` | Size of the extracted text |
| `markdown` or `text` | The full extracted content |
| `chunks` | RAG chunks with `index`, `text` and `characters` (when `chunkSize` is set) |
| `pages` | Text per page (when `includePages` is on) |
| `ocrPages`, `pagesWithoutText`, `needsOcr` | Which pages were read with OCR, with confidence, and which stayed empty |

Each PDF is one item. PDFs that cannot be read (not a PDF, password-protected, too large, unreachable) are **not charged**; they are listed with the reason in the `SUMMARY` record of the run.

### Pricing

- **$0.003 per PDF** extracted.
- **$0.0001 per page** extracted.
- **$0.004 per OCR page**, only for pages that needed OCR (scanned pages in Auto mode).

A 10-page PDF costs $0.0040; 1,000 ten-page PDFs cost $4.00. Failed files cost nothing. Use **Max pages per PDF** to cap long documents.

### FAQ

**Does it do OCR on scanned PDFs?** Yes. In **Auto** mode, pages that have no text layer are rendered and read with Tesseract OCR; digital pages use their exact text. Set **OCR languages** for non-English documents (for example `spa` or `eng+deu`). `ocrPages` lists the pages read with OCR and their confidence; pages that stayed empty are in `pagesWithoutText`. A typical OCR page takes a few seconds; give the run more memory (2–4 GB) for long scans.

**Are tables preserved?** Table cells come out as text in reading order. Complex tables may need post-processing.

**Can I pass files from my computer?** Upload them anywhere that gives a direct link (for example an Apify key-value store or a public bucket) and paste the links.

**Is the PDF stored?** No. Files are downloaded, extracted in memory and discarded; only the extracted text is saved to your dataset.

**Password-protected PDFs?** They are skipped and reported in the summary.

**Word, Excel or images?** Only PDF files are supported. Export other documents to PDF first.

### Limitations

- Links must point to the PDF file itself, not to a viewer page or a login-protected portal.
- Tables, charts and multi-column layouts come out as text in reading order, not as structured tables.
- OCR quality depends on the scan: low-resolution or handwritten pages give lower confidence.

### Use it from your code, AI agents and automations

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("richiedc95/pdf-text-extractor").call(run_input={
    "pdfUrls": [
        "https://arxiv.org/pdf/1706.03762"
    ],
    "outputFormat": "markdown",
    "chunkSize": 1500
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**JavaScript**

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('richiedc95/pdf-text-extractor').call({
    "pdfUrls": [
        "https://arxiv.org/pdf/1706.03762"
    ],
    "outputFormat": "markdown",
    "chunkSize": 1500
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

- 🤖 **AI agents (MCP)**: add the [Apify MCP server](https://mcp.apify.com) to Claude, ChatGPT, Cursor or any MCP client and this Actor becomes a tool your agent can call.
- 🔗 **No-code (n8n, Make, Zapier)**: one HTTP request runs the Actor and returns the results, so any automation tool can use it. In n8n, add an *HTTP Request* node with method `POST`, URL `https://api.apify.com/v2/acts/richiedc95~pdf-text-extractor/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>` and the JSON input above as the body, then send the items to Slack, Google Sheets, email or a CRM. Put a *Schedule* node in front for daily alerts. Make and Zapier have official Apify apps (*Run an Actor* → *Get dataset items*). Ready-made n8n workflows (import from URL) and a step-by-step guide: [n8n / Make / Zapier examples](https://github.com/richiedc95/job-search-mcp/blob/main/examples/README.md).
- 📥 **Exports**: download every run as JSON, CSV, Excel, XML or RSS, or read it through the [Apify API](https://docs.apify.com/api/v2).

### Process new PDFs automatically

1. Click **Save as a new task** with your input.
2. Add a **schedule** to the task, or trigger it from another Actor with an **integration** (for example, run it on the document links a scraper just found).
3. Read the latest results from one stable URL:

```text
https://api.apify.com/v2/actor-tasks/<TASK_ID>/runs/last/dataset/items?token=<YOUR_APIFY_TOKEN>&status=SUCCEEDED&format=json
```

### Related Actors

- [Global News Scraper](https://apify.com/richiedc95/global-news-scraper): worldwide news with sentiment, every 15 minutes.
- [Career Site Jobs Scraper](https://apify.com/richiedc95/career-site-jobs-scraper): all open jobs from any company careers page.
- [Public Tenders Scraper](https://apify.com/richiedc95/public-tenders-scraper): government tenders and contract notices.

Found a bug or need a feature? Open an issue on the Issues tab and we will usually answer within a day.

# Actor input Schema

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

Direct links to PDF files (http or https). Each PDF is one result.

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

Markdown keeps the document structure (headings detected from font size, bullet lists). Plain text is paragraphs only.

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

Split each document into chunks of about this many characters, on paragraph and sentence boundaries, ready for embeddings. 0 = no chunks. 1000–2000 is typical.

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

Characters repeated between consecutive chunks so context is not cut mid-idea.

## `includePages` (type: `boolean`):

Add a "pages" array with the text of each page (for citations with page numbers).

## `maxPagesPerPdf` (type: `integer`):

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

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

Larger files are skipped (and not charged).

## `ocrMode` (type: `string`):

Scanned pages have no text layer; OCR reads them as images. Auto only OCRs those pages, so digital PDFs cost nothing extra.

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

Tesseract language codes, joined with +. Examples: eng, spa, fra, deu, por, ita, nld, chi_sim, jpn, ara, or eng+spa for mixed documents.

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

Cap on OCR pages per document, to control cost on very long scans.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "outputFormat": "markdown",
  "chunkSize": 0,
  "chunkOverlap": 150,
  "includePages": false,
  "maxPagesPerPdf": 0,
  "maxFileSizeMb": 50,
  "ocrMode": "auto",
  "ocrLanguages": "eng",
  "maxOcrPagesPerPdf": 50
}
```

# Actor output Schema

## `documents` (type: `string`):

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("richiedc95/pdf-text-extractor").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("richiedc95/pdf-text-extractor").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 richiedc95/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,richiedc95/pdf-text-extractor"
        }
    }
}
```

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/M00UkjeaCVKSrS1vn/builds/N8vODZ2ncOWWWvHS5/openapi.json
