# PDF Text Extractor - PDF to Text & Markdown for LLM/RAG (`teddythebuilder/pdf-text-extractor`) Actor

Extract text from PDF files by URL, or from all PDFs linked on a web page. Get full text, Markdown per page, title, dates, page count, table of contents and RAG chunks with page numbers. Detects scanned pages. Fast, no browser. Export JSON/CSV or call via API/MCP.

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

from $1.65 / 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

### What does PDF Text Extractor do?

PDF Text Extractor is a fast **PDF to text and PDF to Markdown converter** for LLMs, RAG pipelines, search indexes and data extraction. Give it PDF links, or web pages that link to PDFs, and it returns the **full text of every PDF**, Markdown split by page, the document **title, subject, keywords, creation and modification dates, page count and table of contents**, and optional **RAG chunks that keep their page numbers**.

It reads the PDF's text layer with the open-source pypdf library, with no browser and no OCR, so it is cheap and quick: a 59-page IRS publication is done in about 3 seconds. Scanned pages without a text layer are detected and flagged.

### Why use PDF Text Extractor?

- **Built for AI pipelines.** Markdown with `## Page N` headings, clean paragraphs (hyphenated line breaks re-joined) and chunks that carry their page number, so your RAG answers can cite "page 12".
- **Find PDFs for you.** Give an investor-relations, publications or downloads page and every linked PDF is extracted. Filter links by words such as `annual-report` or `2025`.
- **Metadata and table of contents.** Title, subject, keywords, creator app, dates and the PDF outline (bookmarks) with page numbers.
- **Honest about scans.** `scannedPages` lists pages without a text layer and `needsOcr` tells you when a whole PDF is an image scan. Those PDFs are free.
- **Pay per PDF, not per megabyte.** A flat price per document including 50 pages; long documents add a small per-page fee. Failed downloads, non-PDF links, encrypted and scanned PDFs are free.
- **Polite.** robots.txt and crawl-delay are respected; files over your size limit are skipped.

### What data can you extract?

| Field | Example | Description |
|---|---|---|
| `url` | `https://www.irs.gov/pub/irs-pdf/fw9.pdf` | PDF link |
| `fileName` | `fw9.pdf` | File name |
| `fileSizeKb` | `137.5` | File size |
| `title` | `Form W-9 (Rev. March 2024)` | Title from the PDF metadata |
| `subject` | `Request for Taxpayer Identification Number and Certification` | Subject metadata |
| `keywords` | `Fillable` | Keywords metadata |
| `creator` / `producer` | `Designer 6.5` | App that made the PDF |
| `createdAt` / `modifiedAt` | `2024-03-06T08:18:13` | Document dates |
| `pageCount` | `6` | Pages in the PDF |
| `pagesExtracted` | `6` | Pages read (see `maxPagesPerPdf`) |
| `wordCount` / `charCount` | `6519` / `37732` | Size of the extracted text |
| `outline` | `[{"level": 1, "title": "Introduction", "page": 2}]` | Table of contents (bookmarks) |
| `markdown` | `## Page 1\n\nForm W-9 …` | Text with one heading per page |
| `text` | `Form W-9 Request for Taxpayer…` | Full plain text |
| `pageTexts` | `[{"page": 1, "text": "…"}]` | Text per page (optional) |
| `chunks` | `[{"index": 0, "page": 1, "text": "…", "chars": 1480}]` | RAG chunks (optional) |
| `scannedPages` | `[3, 4]` | Pages without a text layer |
| `needsOcr` | `false` | True when no page has a text layer |
| `isEncrypted` | `false` | Encrypted PDF |
| `error` | `http_404`, `not_a_pdf (text/html)`, `no_text_layer` | Why a PDF returned no text (free row) |

### How to use PDF Text Extractor (step by step)

1. Click **Try for free**.
2. Paste PDF links into **PDF URLs**, or put a page that links to PDFs into **Web pages with PDF links**.
3. Optional: set **RAG chunk size**, switch on **text per page** or **keep layout** for tables, or limit **Max pages per PDF**.
4. Click **Start**.
5. Open the **PDFs** view, or download the dataset as JSON, CSV or Excel.

### Input example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "chunkSize": 1500,
  "chunkOverlap": 150
}
```

Find and extract every W-4 PDF linked on a page:

```json
{
  "pageUrls": ["https://www.irs.gov/forms-instructions"],
  "pdfLinkContains": ["w-4", "w4"],
  "maxPdfs": 10
}
```

### Output example

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "loadedUrl": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "statusCode": 200,
  "fileName": "fw9.pdf",
  "fileSizeKb": 137.5,
  "title": "Form W-9 (Rev. March 2024)",
  "subject": "Request for Taxpayer Identification Number and Certification",
  "keywords": "Fillable",
  "creator": "Designer 6.5",
  "producer": "Designer 6.5",
  "createdAt": "2024-03-06T08:18:13",
  "modifiedAt": "2024-03-06T08:18:13",
  "pageCount": 6,
  "pagesExtracted": 6,
  "wordCount": 6519,
  "charCount": 37732,
  "scannedPages": [],
  "needsOcr": false,
  "isEncrypted": false,
  "outline": [],
  "markdown": "## Page 1\n\nForm W-9\n(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification …",
  "text": "Form W-9\n(Rev. March 2024)\nRequest for Taxpayer …",
  "scrapedAt": "2026-10-21T20:10:00Z"
}
```

### How much does it cost?

PDF Text Extractor uses pay-per-event pricing.

| Event | Price (Free plan) | When it is charged |
|---|---|---|
| Actor start | $0.0005 | Once per run |
| PDF extracted | $0.003 ($3 per 1,000 PDFs) | One PDF with text, **including its first 50 pages** |
| Extra page | $0.0001 ($0.10 per 1,000 pages) | Each page beyond the first 50 of a PDF |

Failed downloads, links that are not PDFs, files over the size limit, encrypted PDFs without the password and scanned PDFs without a text layer are **free**. Paid Apify plans get Store discounts (Bronze −15%, Silver −30%, Gold and up −45%).

Worked examples (Free plan prices):

- **1,000 invoices or forms** of 1–5 pages: ≈ **$3**.
- **A 300-page annual report**: $0.003 + 250 × $0.0001 ≈ **$0.03**.
- **All 40 PDFs on an investor-relations page**, 80 pages each: 40 × ($0.003 + 30 × $0.0001) ≈ **$0.24**.
- **The first 10 pages of 5,000 research papers** (`maxPagesPerPdf: 10`): ≈ **$15**.

### Use cases

- **RAG and chatbots.** Load manuals, policies, contracts and reports into a vector database with page-aware chunks.
- **Financial research.** Pull text from annual reports, 10-Ks, prospectuses and ESG reports linked on investor-relations pages, then search or summarise them.
- **Legal and compliance.** Extract terms, regulations and filings to compare versions or feed review tools.
- **Academic research.** Read papers in bulk (abstracts, sections via the outline) for literature reviews.
- **Procurement and tenders.** Extract the text of tender documents and specifications for keyword alerts.
- **AI agents.** Give an agent a tool that turns any PDF link into text it can reason over.

### Tips for better results

- **Cheap previews.** Set `maxPagesPerPdf` to 2–5 to read only the cover and summary pages of long reports, then run the full extraction only on the documents you need.
- **Chunk sizes.** 1,000–2,000 characters with 10% overlap works well for most embedding models. Chunks never cross a page boundary, so each one cites a single page.
- **Tables.** Turn on **Keep layout** for financial statements and price lists; the text keeps the column positions, which LLMs read much better than run-together numbers.
- **Discovery pages.** Use `pdfLinkContains` to pick only the documents you want from busy download pages (e.g. `annual`, `q3`, `sustainability`).
- **Dates.** `createdAt` and `modifiedAt` come from the PDF itself and tell you whether a document has changed since your last run.

### Use with AI agents, MCP and the API

```bash
curl -X POST "https://api.apify.com/v2/acts/teddythebuilder~pdf-text-extractor/run-sync-get-dataset-items?token=<TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"pdfUrls":["https://www.irs.gov/pub/irs-pdf/fw9.pdf"]}'
```

Python with `apify-client`:

```python
from apify_client import ApifyClient

client = ApifyClient("<TOKEN>")
run = client.actor("teddythebuilder/pdf-text-extractor").call(run_input={
    "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
    "chunkSize": 1500,
    "chunkOverlap": 150,
})
for pdf in client.dataset(run["defaultDatasetId"]).iterate_items():
    for chunk in pdf.get("chunks", []):
        print(pdf["title"], "page", chunk["page"], chunk["chars"])
```

**MCP:** available as a tool in the Apify MCP server (`https://mcp.apify.com`) for Claude, ChatGPT, Cursor and other MCP clients.

### Integrations

Send results to Google Drive, Google Sheets, Airtable, Slack, Make, Zapier, n8n, LangChain, LlamaIndex or a webhook when a run finishes.

### Data source and legality

The actor downloads the PDF files you point it to (or that are linked on the pages you give) over HTTP, after checking each site's **robots.txt**. It does not log in, bypass paywalls or break DRM; encrypted PDFs are only opened with a password you provide. Text is extracted with pypdf (BSD licence).

You are responsible for the documents you process: copyright, confidentiality and data-protection rules apply to their content, which can include names and contact details.

### FAQ

**Does it do OCR on scanned PDFs?**
No. It reads the text layer, which almost all digitally created PDFs have. Scanned pages are listed in `scannedPages`; a PDF that is entirely scanned returns a free row with `needsOcr: true`.

**How good is the text for tables and multi-column layouts?**
The default mode follows the natural reading order. Switch on **Keep layout** to keep table columns aligned with spaces.

**What is the maximum file size?**
50 MB by default, up to 200 MB with `maxFileSizeMb`. Raise the memory for very large files.

**Which links count as PDF links on a web page?**
Links ending in `.pdf`, containing `/pdf/` or `format=pdf`. Every candidate is checked for the `%PDF` signature before parsing, and non-PDFs are free.

**Can it read password-protected PDFs?**
Yes, if you provide the password in **PDF password**. Without it, encrypted PDFs return a free error row.

**Can I upload my own files?**
Use a public or pre-signed link (Google Drive direct link, S3, Dropbox `?dl=1`, an Apify key-value store record URL).

**A PDF extracts badly.**
Open an issue with the link. We reply within 24 hours. If the actor helps you, a rating on the Store page helps others find it.

### Related actors

- [Website to Markdown](https://apify.com/teddythebuilder/website-to-markdown): the readable content of web pages and whole sites as Markdown for LLMs.
- [Nordic Tenders Scraper](https://apify.com/teddythebuilder/nordic-public-tenders-monitor): public procurement notices from TED for the Nordic countries.
- [Website SEO Audit Crawler](https://apify.com/teddythebuilder/website-seo-audit): titles, meta, broken links and sitemap checks for a site.
- [Website Contact Scraper](https://apify.com/teddythebuilder/website-contact-scraper): company emails, phones and social profiles from websites.

### Changelog and support

- **1.0 (October 2026):** first release. PDF URLs and PDF link discovery on web pages, text and Markdown per page, metadata and outline, page-aware RAG chunks, scanned-page detection, password support, free error rows.

Questions or feature requests? Open an issue on the actor page. We reply within 24 hours.

# Actor input Schema

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

Direct links to PDF files, e.g. https://www.irs.gov/pub/irs-pdf/fw9.pdf. Leave empty if you use 'Web pages with PDF links'.

## `pageUrls` (type: `array`):

Web pages to scan for links to PDF files (one level), e.g. an investor-relations or downloads page. Every PDF linked there is extracted.

## `pdfLinkContains` (type: `array`):

When scanning web pages, keep only PDF links whose URL or link text contains one of these words, e.g. annual-report or 2025.

## `maxPdfs` (type: `integer`):

Stop after this many PDFs.

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

If > 0, adds a 'chunks' array (each chunk with its page number), e.g. 1500 for embeddings. 0 = no chunks.

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

Characters repeated from the previous chunk, e.g. 150. At most half the chunk size.

## `includePlainText` (type: `boolean`):

Add a 'text' field with the whole document as plain text (the Markdown field is always returned).

## `includePageTexts` (type: `boolean`):

Add a 'pageTexts' array with one entry per page.

## `layoutMode` (type: `boolean`):

Preserve the horizontal layout of each page with spaces, which keeps table columns aligned. Slower; off = natural reading order.

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

Extract only the first N pages of each PDF, e.g. 10 to read summaries cheaply. 0 = all pages.

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

Larger files are skipped (free row).

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

Password for encrypted PDFs, if you have it (the same password is tried on every PDF).

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

PDFs downloaded and parsed at the same time.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
  ],
  "pageUrls": [],
  "pdfLinkContains": [],
  "maxPdfs": 100,
  "chunkSize": 0,
  "chunkOverlap": 0,
  "includePlainText": true,
  "includePageTexts": false,
  "layoutMode": false,
  "maxPagesPerPdf": 0,
  "maxFileSizeMb": 50,
  "maxConcurrency": 3
}
```

# Actor output Schema

## `results` (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://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("teddythebuilder/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://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://www.irs.gov/pub/irs-pdf/fw4.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("teddythebuilder/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://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
  ]
}' |
apify call teddythebuilder/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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