# PDF to Text & RAG Chunks – PDF Text Extractor for LLMs (`mabun/pdf-text-extractor-rag`) Actor

Convert PDF links to clean text for LLMs: one record per document, per page (with page numbers for citations) or overlapping RAG chunks for Pinecone, Qdrant or LangChain. Flags scanned PDFs, reports broken links free of charge. No start fee, $3 per 1,000 PDFs.

- **URL**: https://apify.com/mabun/pdf-text-extractor-rag.md
- **Developed by:** [Maximilian van Elst](https://apify.com/mabun) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$3.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 Text & RAG Chunks – PDF Text Extractor for LLMs

**Paste PDF links, get clean text back** – one record per document, one per page, or **overlapping chunks ready for RAG and vector databases**. No start fee, $3 per 1,000 PDFs, and failed URLs are free. Scanned PDFs without a text layer are flagged so you know what needs OCR.

### What does this PDF Text Extractor do?

- Downloads PDFs from any public **http/https URL**
- Extracts the **text layer** and cleans it (joins hyphenated line breaks, normalizes whitespace)
- Outputs in **3 modes**:
  - `document` – one record per PDF
  - `page` – one record per page (with `pageNumber`)
  - `chunks` – overlapping chunks with configurable size and overlap, split at paragraph/sentence boundaries
- Adds **metadata**: page count, title, creator tool, creation date, PDF version (the author field is deliberately not exported)
- Flags likely **scanned PDFs** (`isLikelyScanned`)
- Reports broken links, HTML pages and oversized files per URL – **errors are free**

### Who is it for?

- **AI / LLM developers** building RAG pipelines with LangChain, LlamaIndex, Pinecone, Qdrant, Weaviate or Chroma
- **Automation builders** who need PDF text in Make, Zapier or n8n
- **Researchers, analysts and journalists** converting reports, papers or parliamentary documents to searchable text
- **AI agents** that need to "read" a PDF link on demand

### Use cases

- 🧠 Feed research papers, manuals or policies into a **vector database** (`chunks` mode)
- 📑 **Page-level citations** – keep `pageNumber` so answers can cite the exact page
- 🔎 Bulk-convert public PDFs to text for **search or keyword monitoring**
- ✅ **Pre-check** a document collection: which files have text, which need OCR

### How to extract text from a PDF in 3 steps

1. Click **Start** – the prefilled input (one arXiv paper, 15 pages, chunks mode) runs in a few seconds and costs $0.003.
2. Paste your own PDF URLs and choose an output mode.
3. Export as JSON, CSV or Excel, or call the Actor from your code or agent.

### Input example

```json
{
  "pdfUrls": [{ "url": "https://arxiv.org/pdf/1706.03762" }],
  "outputMode": "chunks",
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "maxPages": 0,
  "maxFileSizeMb": 50,
  "includeMetadata": true,
  "maxConcurrency": 4
}
```

| Field | Meaning |
|---|---|
| `pdfUrls` | Direct links to PDF files |
| `outputMode` | `document`, `page` or `chunks` |
| `chunkSize` / `chunkOverlap` | Characters per chunk and overlap (chunks mode only) |
| `maxPages` | Process only the first N pages (0 = all) |
| `maxFileSizeMb` | Larger files are skipped and reported (not charged) |
| `includeMetadata` | Add title, creator tool, creation date, PDF version |
| `maxConcurrency` | Parallel downloads (1–20) |

### Output example

Real record from a test run on 22 Oct 2026 (prefilled input: chunks mode, "Attention Is All You Need", arXiv 1706.03762; text shortened):

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "ok",
  "totalPages": 15,
  "pagesProcessed": 15,
  "isLikelyScanned": false,
  "title": null,
  "creatorTool": "LaTeX with hyperref",
  "creationDate": "D:20240410211143Z",
  "pdfVersion": "1.5",
  "processingMs": 1192,
  "chunkIndex": 1,
  "chunkCount": 22,
  "charStart": 1797,
  "charEnd": 3781,
  "charCount": 1983,
  "text": "sed replacing RNNs with self-attention and started\nthe effort to evaluate this idea. Ashish, with Illia, designed and …"
}
```

`document` mode adds `charCount` and `wordCount` per PDF; `page` mode adds `pageNumber`.

Failed URLs return a record like:

```json
{ "url": "https://example.com/", "status": "error", "error": "Not a PDF (content-type: text/html; charset=utf-8)" }
```

### PDF chunking for RAG: which settings?

- **`chunkSize` 1,000–2,000 characters** with **about 10 % overlap** is a common starting point; tune it for your embedding model and documents.
- Use `page` mode if your app must cite page numbers; chunk each page yourself if pages are long.
- Store `url` + `chunkIndex` (or `pageNumber`) as metadata in your vector DB so every answer can link back to the source.

### How much does it cost to extract text from PDFs?

Pay-per-event pricing – you only pay for successfully processed PDFs, platform compute is included:

| Event | Price |
|---|---|
| PDF processed | **$0.003** per PDF ($3 per 1,000), any number of pages up to the size limit |

**No start fee.** Failed URLs (404, HTML instead of PDF, too large) cost nothing.

- Prefilled test run (1 PDF): **$0.003**
- 1,000 PDFs into your vector DB: **$3**
- 10,000 PDFs: **$30**

### PDF to text API: Python, JavaScript, cURL

**Python**

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("mabun/pdf-text-extractor-rag").call(run_input={
    "pdfUrls": [{"url": "https://arxiv.org/pdf/1706.03762"}],
    "outputMode": "chunks", "chunkSize": 1500, "chunkOverlap": 150
})
chunks = list(client.dataset(run["defaultDatasetId"]).iterate_items())
## -> embed chunk["text"] and store chunk["url"], chunk["chunkIndex"] as metadata
```

**JavaScript**

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('mabun/pdf-text-extractor-rag').call({
  pdfUrls: [{ url: 'https://arxiv.org/pdf/1706.03762' }], outputMode: 'page'
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

**cURL**

```bash
curl -X POST "https://api.apify.com/v2/acts/mabun~pdf-text-extractor-rag/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"pdfUrls":[{"url":"https://arxiv.org/pdf/1706.03762"}],"outputMode":"document"}'
```

### Use with AI agents (MCP)

Let Claude, ChatGPT, Cursor or your own agent read PDF links through the Apify MCP server:
`https://mcp.apify.com?tools=mabun/pdf-text-extractor-rag`
Example prompt: *"Read this PDF and summarize sections 3 and 4 with page references: https://arxiv.org/pdf/1706.03762"*

### Integrations

- **Schedules** – re-process a list of documents regularly
- **Webhooks** – notify your backend when extraction is done
- **Make, Zapier, n8n, Google Drive, Airtable** – via Apify's ready-made integrations
- **LangChain / LlamaIndex** – load the dataset with the Apify document loaders

### FAQ

**Does it do OCR?** No. It extracts the existing text layer, which is why it is fast and cheap. Scanned PDFs are flagged with `isLikelyScanned: true` so you can route only those to an OCR tool.

**Does it output Markdown or tables?** No – clean plain text. Table contents come out as plain text without table structure.

**Can it read password-protected PDFs or PDFs behind a login?** No – only publicly reachable, unencrypted PDFs.

**Which languages are supported?** Any language with a text layer; tested with English and German documents.

**How are chunks split?** At paragraph or sentence boundaries near your `chunkSize`, with `chunkOverlap` characters repeated between chunks. `charStart`/`charEnd` refer to the cleaned full text.

**Can I upload local files?** Put them in an Apify key-value store or any public storage and pass the URLs.

### Limitations

- No OCR, no table structure or images – plain text only
- Complex layouts (multi-column, formulas) may produce imperfect reading order
- `isLikelyScanned` is a heuristic (fewer than 10 characters per page); very short PDFs can trigger it
- Default max file size 50 MB (configurable up to 200 MB)
- Only process documents you are allowed to use

### Related Actors by the same developer

- [RSS Feed Monitor](https://apify.com/mabun/rss-feed-monitor) – new items from any feed, ideal input for a RAG news index
- [EU Tenders Monitor Germany & Austria (TED)](https://apify.com/mabun/ted-tenders-dach) – new public tenders from Germany & Austria via the official TED API
- [EPO Patent Search & Monitor](https://apify.com/mabun/epo-patent-search) – new European patents by keyword, applicant or CPC

### Support

Found a PDF that does not extract well? Open an issue on the **Issues** tab with the URL.

# Actor input Schema

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

Direct links to PDF files (http/https). Only process documents you are allowed to use.

## `outputMode` (type: `string`):

document = one record per PDF, page = one record per page, chunks = overlapping text chunks for RAG / vector databases.

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

Only for chunks mode.

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

Only for chunks mode.

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

0 = all pages.

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

Larger files are skipped and reported.

## `includeMetadata` (type: `boolean`):

Title, creator tool, creation date, page count. The author field is excluded on purpose.

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

How many PDFs to process at the same time.

## Actor input object example

```json
{
  "pdfUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "outputMode": "chunks",
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "maxPages": 0,
  "maxFileSizeMb": 50,
  "includeMetadata": true,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `extractedText` (type: `string`):

Extracted text and metadata per document, page or chunk (url, status, page/chunk index, character count, scanned flag, text).

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

// Run the Actor and wait for it to finish
const run = await client.actor("mabun/pdf-text-extractor-rag").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": [{ "url": "https://arxiv.org/pdf/1706.03762" }],
    "outputMode": "chunks",
}

# Run the Actor and wait for it to finish
run = client.actor("mabun/pdf-text-extractor-rag").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": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "outputMode": "chunks"
}' |
apify call mabun/pdf-text-extractor-rag --silent --output-dataset

```

## MCP server setup

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

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/gVW90oNjXEHF5bgeH/builds/XTsDtUgLWsTdG5Eh6/openapi.json
