# PDF Text Extractor: text, pages, outline, links, RAG chunks (`kvnloo/pdf-text-extractor`) Actor

Turn PDF URLs or uploaded files into clean text with per-page text, metadata, outline (bookmarks), links and RAG-ready chunks. Page ranges and passwords. $2 per 1,000 PDFs, failed and scanned PDFs free.

- **URL**: https://apify.com/kvnloo/pdf-text-extractor.md
- **Developed by:** [Kevin Rajan](https://apify.com/kvnloo) (community)
- **Categories:** Developer tools, AI
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 pdf extracteds

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 Text Extractor: PDF to text, pages, outline, links and RAG chunks

Turn PDF links or uploaded PDF files into clean, structured text. For each PDF you get:

- the full text and the text of each page
- document metadata
- the outline (bookmarks)
- the clickable links
- optional chunks sized for retrieval-augmented generation (RAG)

It costs **$2 per 1,000 PDFs**, with a $0.00005 start fee. Failed, password-locked and scanned (image-only) PDFs are free.

Use it for:

- **RAG and LLM pipelines.** Chunks come with the page span they cover, ready for embeddings.
- **Search indexes and knowledge bases.** Get clean full text plus the title, outline and dates.
- **Research and compliance.** Extract government forms, filings, papers and manuals in bulk.
- **Change monitoring.** Each file gets a SHA-256 hash, so you can tell when a PDF at the same URL changed.

### What it does

1. **Downloads each PDF.** Redirects are followed. The size limit and time limit are enforced during the transfer, and a link that turns out to be a web page is stopped after its first kilobyte.
2. **Extracts the text** with PDFium, the PDF engine inside Google Chrome. It is fast and accurate on multi-column layouts and forms, and handles both RC4 and AES-256 encryption.
3. **Cleans the text.** Words split across lines with soft hyphens are rejoined, line ends are normalized and control characters are removed.
4. **Flags scanned pages** (images with no text layer). A PDF that is entirely scanned is reported as `no_text` and is not charged.

Every PDF runs in its own process with a hard time limit. A broken or hostile file cannot hang or crash the run; it becomes a row with an `error` code.

### Input

| Field | What it does | Default |
|---|---|---|
| `urls` | Up to 5,000 links to PDF files | IRS Form 1040 and a W3C sample (only when the input is empty) |
| `base64Pdfs` | Up to 50 inline PDFs, as base64 strings or `{"filename", "data"}` objects, for files that are not on a public URL | none |
| `pageRange` | Pages to extract, for example `1-5, 8, 12-` | all pages |
| `password` | Password for protected PDFs. The field is stored encrypted. | none |
| `includeText`, `includePages`, `includeLinks` | Turn individual output fields on or off | on |
| `chunkSize`, `chunkOverlap` | Chunk size in characters for RAG (0 = off), and the overlap between chunks | 0, 200 |
| `maxPdfSizeMb`, `timeoutSecs`, `concurrency` | Limits per PDF, and the number of PDFs processed in parallel | 50 MB, 120 s, 4 |

```json
{
  "urls": ["https://www.irs.gov/pub/irs-pdf/f1040.pdf"],
  "pageRange": "1-2",
  "chunkSize": 2000
}
```

### Output

One dataset row per PDF. Shortened example:

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
  "fileName": "f1040.pdf",
  "status": "ok",
  "error": null,
  "charged": true,
  "fileSizeBytes": 220237,
  "sha256": "3d31c226df0d189c…",
  "pdfVersion": "1.7",
  "pageCount": 2,
  "isEncrypted": false,
  "isTagged": true,
  "title": "2025 Form 1040",
  "subject": "U.S. Individual Income Tax Return",
  "creator": "Designer 6.5",
  "createdAt": "2026-01-02T13:24:31Z",
  "textLayer": "full",
  "scannedPages": [],
  "wordCount": 2230,
  "text": "Form 1040 U.S. Individual Income Tax Return 2025 …",
  "pages": [{"page": 1, "label": null, "text": "…", "charCount": 5341, "wordCount": 1098}],
  "outline": [],
  "links": [],
  "chunks": [{"index": 0, "text": "…", "pageStart": 1, "pageEnd": 1, "charCount": 1999}],
  "truncated": [],
  "processingMs": 391
}
```

A book-like PDF also fills `outline` (for example 122 bookmarks for IRS Publication 17) and `links` (146 links). Dates are converted to UTC from the time zone written in the PDF. The Store view has a **PDFs** table and a **Text** table. You can export as JSON, CSV, Excel or HTML, or connect the dataset to Make, Zapier, Google Sheets or a webhook.

#### Status and error codes

| `status` | Meaning | Charged |
|---|---|---|
| `ok` | Text extracted | Yes |
| `no_text` | No text layer: a scan or an image-only PDF (see `scannedPages`) | No |
| `failed` | See `error`: `http_404`, `timeout`, `unreachable`, `too_large`, `not_pdf`, `password_required`, `wrong_password`, `corrupt`, `parse_timeout`, `parse_failed`, `page_range_out_of_bounds` | No |
| `skipped` | Your maximum charge per run was reached | No |

### Pricing

Pay per event, with prices that fall at higher Apify subscription tiers:

| Event | Free / Bronze | Silver | Gold | Platinum | Diamond |
|---|---|---|---|---|---|
| PDF extracted (up to 1,000 pages) | $0.002 | $0.0015 | $0.001 | $0.001 | $0.001 |
| Actor start | $0.00005 | | | | |

A PDF over 1,000 pages counts as one event per started 1,000 pages. Failed, scanned and skipped PDFs are free. To control spend, set a maximum charge per run: the Actor stops cleanly when it reaches the limit.

### How it compares

Measured on 2026-11-15, on the same two PDFs (IRS Form 1040 and a W3C sample table):

| | **This Actor** | automation-lab/pdf-text-extractor | memo23/pdf-text-extractor |
|---|---|---|---|
| Price per PDF (Free plan) | **$0.002** | $0.00345 | $0.005 |
| Start fee | **$0.00005** | $0.005 | $0.005 |
| Cost of this 2-PDF run | **$0.00405** | $0.0119 | $0.015 |
| Dates | **UTC, offset applied** | Local time labelled as UTC (6 h off on Form 1040) | in metadata |
| Outline / bookmarks | **Yes** | No | No |
| Clickable links | **Yes** | No | No |
| RAG chunks with page span | **Yes** | No | No |
| Page ranges, passwords, base64 input | **Yes** | No | Yes |
| Scanned-page detection | **Per page, not charged** | Status flag | OCR (paid per page) |
| Author names | **Not output** (personal data) | Output | Output |
| Markdown, OCR | No | No | Yes |

If you need OCR for scanned documents, memo23's Actor offers it at $0.015 per page. For text-layer PDFs, this Actor is cheaper and returns more structure.

### FAQ

**Can it read scanned PDFs?** It detects them and lists the scanned pages in `scannedPages`, but it does not run OCR. Fully scanned PDFs are not charged.

**Why is the author missing?** The Author field usually holds a person's name. It is left out so your dataset contains no personal data. Title, subject, keywords, the creating application, the producer and dates are all kept.

**What about very large PDFs?** A dataset row can hold up to 9 MB. When a PDF's text exceeds that, the row drops the `chunks`, then the `pages`, then cuts the `text`, and lists what was cut in `truncated`. To get everything from a book-length PDF, split it with `pageRange` (for example `1-500` and `501-`).

**How do I send a file that isn't online?** Call the Actor through the API with `base64Pdfs`, for example `[{"filename": "report.pdf", "data": "<base64>"}]`.

**Is my password logged?** No. The input field is stored encrypted and is only used to open the PDF.

**Is this legal?** You choose which PDFs to process. Only process documents you are allowed to access, and respect each site's terms of use.

**Something broke?** Open an issue on the Issues tab with the PDF URL. Fixes for specific files usually ship the same day.

# Actor input Schema

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

Up to 5,000 direct links to PDF files. Redirects are followed. Each PDF becomes one dataset row.

## `base64Pdfs` (type: `array`):

Up to 50 PDFs sent inline: base64 strings (a data: URI prefix is fine) or objects {"filename": "doc.pdf", "data": "<base64>"}. Useful from the API when the file is not on a public URL.

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

Extract only these pages, for example 1-5, 8, 12- (12- = page 12 to the end). Empty = all pages. Pages past the end of a PDF are ignored.

## `password` (type: `string`):

Opens password-protected PDFs. Applied to every PDF that asks for one.

## `includeText` (type: `boolean`):

Output the whole document text in the text field.

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

Output a pages array with each page's number, printed label, text and word count. Turn off to keep rows small.

## `includeLinks` (type: `boolean`):

Output the clickable web links (URI annotations) in the PDF with the page they are on.

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

0 = off. Otherwise also split the text into chunks of about this many characters at word boundaries, each with its page span, ready for embeddings. 1,000 to 4,000 suits most embedding models.

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

Characters repeated at the start of the next chunk, so a sentence cut at a boundary keeps its context. Capped at half the chunk size.

## `maxPdfSizeMb` (type: `integer`):

Larger files are skipped as too_large (free). The limit is enforced while downloading.

## `timeoutSecs` (type: `integer`):

Download plus extraction. A PDF over the limit is stopped and reported as timeout or parse_timeout (free).

## `concurrency` (type: `integer`):

Downloads from the same host start at most twice per second.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ],
  "base64Pdfs": [],
  "pageRange": "",
  "includeText": true,
  "includePages": true,
  "includeLinks": true,
  "chunkSize": 0,
  "chunkOverlap": 200,
  "maxPdfSizeMb": 50,
  "timeoutSecs": 120,
  "concurrency": 4
}
```

# Actor output Schema

## `results` (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 = {
    "urls": [
        "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
        "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("kvnloo/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 = { "urls": [
        "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
        "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("kvnloo/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 '{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ]
}' |
apify call kvnloo/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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