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

Extract clean text, Markdown, per-page text, metadata and ready-to-embed RAG chunks from any PDF URL. Fast, no browser, bulk friendly. $2 per 1,000 PDFs, failed files are free.

- **URL**: https://apify.com/sonnguyenauctor/pdf-text-extractor.md
- **Developed by:** [HONG SON NGUYEN](https://apify.com/sonnguyenauctor) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.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 Text Extractor - PDF to Text, Markdown & RAG Chunks

Turn any PDF link into clean, structured data. Give it one URL or ten thousand, and get back the plain text, a Markdown version with real headings, the text of every page, the document metadata, and optional ready-to-embed chunks for your vector database.

No browser, no OCR delay, no setup. It is fast and cheap: **$2 per 1,000 PDFs**.

### What does PDF Text Extractor do?

For every PDF URL you give it, the Actor downloads the file, reads its text layer and returns one row with:

- **Plain text**: the full text with paragraphs kept apart and broken words re-joined.
- **Markdown**: headings detected from font size (`#`, `##`, `###`), bullet lists and paragraphs, so LLMs understand the structure.
- **Text per page**: each page's text with its page number, for citations and "page 12 says..." answers.
- **RAG chunks**: the text split into overlapping chunks of the size you choose, each with its start and end page.
- **Metadata**: title, author, subject, keywords, creator, producer, creation and modification dates, PDF version, file size, page count and word count.
- **Scanned PDF warning**: if most pages have no text layer, the row is flagged `likelyScanned: true`, so you know which files need OCR.

### Who is it for?

- **AI and RAG builders** who need PDF content in a vector database (Pinecone, Qdrant, Weaviate, pgvector...) with page numbers kept.
- **Researchers and analysts** who need to read reports, papers, filings or tenders in bulk.
- **Automation users** (Make, Zapier, n8n) who want "PDF link in, text out" without running their own server.
- **Developers** who don't want to maintain a PDF parsing stack.

### Why use it?

- **Cheap and predictable**: you pay per PDF that was read successfully. Failed downloads and non-PDF links are free.
- **Fast**: pure text extraction, no headless browser. A normal 20-page PDF takes well under a second to parse.
- **Structure kept**: paragraphs, headings and lists survive, unlike a raw text dump.
- **Bulk friendly**: paste a list or upload a file of URLs; several PDFs are processed in parallel.

### How much does it cost?

This Actor uses pay-per-event pricing. You pay **$0.002 per PDF processed** (that is $2 per 1,000 PDFs), plus a tiny start fee per run. There are no extra platform usage costs.

| PDFs | Price |
| --- | --- |
| 100 | $0.20 |
| 1,000 | $2.00 |
| 10,000 | $20.00 |

PDFs that fail (broken link, not a PDF, too big, timeout) are **not charged**. You can set a maximum cost per run in the run options and the Actor stops cleanly when it is reached.

### How to use it

1. Click **Try for free**.
2. Paste your PDF URLs into **PDF URLs** (or upload a .txt file with one URL per line).
3. Choose what you want back: plain text, Markdown, text per page, RAG chunks.
4. Click **Start** and download the results as JSON, CSV, Excel or via the API.

### Input

| Field | What it does | Default |
| --- | --- | --- |
| `pdfUrls` | Direct links to PDF files | required |
| `includeFullText` | Add the full plain text | `true` |
| `includeMarkdown` | Add a Markdown version | `true` |
| `includePages` | Add text for each page | `false` |
| `chunkSize` | RAG chunk size in characters (0 = off) | `0` |
| `chunkOverlap` | Characters repeated between chunks | `200` |
| `maxPagesPerPdf` | Read only the first N pages | `500` |
| `maxFileSizeMb` | Skip files larger than this | `50` |
| `requestTimeoutSecs` | Download timeout | `60` |
| `maxConcurrency` | PDFs processed at the same time | `4` |

Example input:

```json
{
    "pdfUrls": [
        { "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" }
    ],
    "includeMarkdown": true,
    "includePages": true,
    "chunkSize": 1500,
    "chunkOverlap": 200
}
```

### Output

One row per PDF. Example (text shortened):

```json
{
    "url": "https://example.com/report.pdf",
    "status": "OK",
    "error": null,
    "fileName": "report.pdf",
    "fileSizeBytes": 248311,
    "pageCount": 2,
    "pagesExtracted": 2,
    "wordCount": 354,
    "charCount": 2270,
    "likelyScanned": false,
    "title": "Quarterly Report",
    "author": "Jane Doe",
    "createdAt": "2026-11-16T00:08:20Z",
    "text": "Quarterly Report 2026\n\n1. Introduction\n\nThis is paragraph 0...",
    "markdown": "# Quarterly Report 2026\n\n# 1. Introduction\n\nThis is paragraph 0...\n\n## Key results\n\n- Revenue grew 12%",
    "pages": [
        { "page": 1, "charCount": 1490, "text": "..." }
    ],
    "chunks": [
        { "index": 0, "pageStart": 1, "pageEnd": 1, "charCount": 1497, "text": "..." }
    ]
}
```

A failed PDF looks like this, and is not charged:

```json
{ "url": "https://example.com/missing.pdf", "status": "ERROR", "error": "Download failed: HTTP 404" }
```

The run also saves a `SUMMARY` record in the key-value store with the number of PDFs processed and failed, total pages and total words.

### Integrations and API

Run it from your own code with the Apify API or client:

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('sonnguyenauctor/pdf-text-extractor').call({
    pdfUrls: [{ url: 'https://www.irs.gov/pub/irs-pdf/fw9.pdf' }],
    chunkSize: 1500,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].markdown);
```

It also works with Make, Zapier, n8n, LangChain, LlamaIndex and as a tool for AI agents through the Apify MCP server.

### Limitations

- **Scanned PDFs** (images of pages with no text layer) return little or no text. They are flagged with `likelyScanned: true` so you can send them to an OCR tool.
- **Tables** come out as text lines, not as structured cells.
- **Password-protected PDFs** cannot be read and are reported as errors.
- The PDF link must be publicly downloadable. Links that need a login won't work.

### FAQ

**Do I pay for PDFs that fail?** No. Only PDFs that were read successfully are charged.

**How are headings detected?** From font size: lines clearly larger than the body text become `#`, `##` or `###` headings.

**What chunk size should I use for RAG?** 1,000-2,000 characters with 150-300 characters overlap works well for most embedding models.

**Is there a page limit?** By default the first 500 pages of each PDF are read. You can raise it to 5,000.

Found a bug or need a feature? Open an issue on the **Issues** tab and include the run link.

# Actor input Schema

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

Direct links to PDF files (http or https). You can paste many at once or upload a text file with one URL per line.

## `includeFullText` (type: `boolean`):

Add the full plain text of the PDF in the "text" field. Paragraphs are separated by blank lines.

## `includeMarkdown` (type: `boolean`):

Add a Markdown version with headings (detected from font size), bullet lists and paragraphs. Pages are separated by ---.

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

Add a "pages" array with the text of each page and its page number. Useful for citations.

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

Split the text into chunks of about this many characters for vector databases and LLMs. Each chunk keeps its start and end page. Set 0 to turn off.

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

How many characters each chunk repeats from the previous one.

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

Only the first N pages of each PDF are read.

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

Larger files are skipped and reported as an error (not charged).

## `requestTimeoutSecs` (type: `integer`):

How long to wait for each PDF to download before giving up. Timed-out PDFs are not charged.

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

How many PDFs are processed at the same time.

## Actor input object example

```json
{
  "pdfUrls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    },
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ],
  "includeFullText": true,
  "includeMarkdown": true,
  "includePages": false,
  "chunkSize": 0,
  "chunkOverlap": 200,
  "maxPagesPerPdf": 500,
  "maxFileSizeMb": 50,
  "requestTimeoutSecs": 60,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

One row per PDF with text, Markdown, metadata, pages and chunks.

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

Totals for the run: PDFs processed and failed, pages and words.

# 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://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
        },
        {
            "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("sonnguyenauctor/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": [
        { "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" },
        { "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("sonnguyenauctor/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": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    },
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ]
}' |
apify call sonnguyenauctor/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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