# PDF Text Extractor: Text, Pages & Metadata from PDF (OCR) (`fguiraud/pdf-text-extractor`) Actor

Extract the text of any PDF (native or scanned with OCR), Word, PowerPoint, Excel or web page: full text, text per page, page count, title, author and dates as JSON, CSV or Excel. Bulk URLs or uploads, no API key. Pay per document.

- **URL**: https://apify.com/fguiraud/pdf-text-extractor.md
- **Developed by:** [Fernando Guiraud](https://apify.com/fguiraud) (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 $3.00 / 1,000 documents

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

### What does PDF Text Extractor do?

**PDF Text Extractor** gets the **text out of any PDF** and gives it back as **clean JSON, CSV or Excel**: the **full text**, the **text of each page**, the **page count** and the document's **title, author, language and dates**. It reads **native and scanned PDFs** (OCR for pages without a text layer) and also **Word (DOCX), PowerPoint (PPTX), Excel, web pages and images**.

Paste PDF URLs (Google Drive, Dropbox and OneDrive share links work) or upload files, and get one row per document. No API key, no browser, and you **pay only per document processed**, however many pages it has.

It runs on the Apify platform, so you also get an API, scheduling, integrations (Google Sheets, Make, Zapier, n8n) and access for **AI agents through the [Apify MCP server](https://mcp.apify.com)**.

### Why use it?

- 📄 **Bulk PDF to text**: contracts, reports, invoices, research papers, government forms, thousands at a time.
- 🔎 **Text per page**: search, cite or split documents by page.
- 🖨️ **Scanned PDFs**: pages without text are read with OCR (7 languages), and only those pages are billed as OCR.
- 🏷️ **Metadata included**: title, author, subject, creator, creation and modification dates, page count and detected language.
- 🧹 **Clean text**: repeated headers and footers removed, two-column layouts read in the right order.
- 🤖 **For AI and RAG**: switch on `markdown` or `chunks` to get LLM-ready Markdown or pieces with page numbers.

### How to extract text from a PDF

1. Click **Try for free**.
2. Paste one or more PDF (or DOCX/PPTX/XLSX/HTML) URLs, or upload files.
3. Click **Start**.
4. Read the **Documents** view, or download the dataset as JSON, CSV or Excel.

### Input

| Field | Description | Default |
|---|---|---|
| `sources` | Document URLs (PDF, DOCX, PPTX, XLSX, HTML, images; share links work) | `sources` or `base64Files` |
| `base64Files` | Files sent inline (for APIs and AI agents) | - |
| `outputs` | `text`, `pages`, `markdown`, `tables`, `chunks` | `text`, `pages` |
| `ocr` | `auto` (only pages without text), `always` or `never` | `auto` |
| `pageRange` | e.g. `1-5, 8` | all pages |
| `pdfPassword` | Password of encrypted PDFs | - |
| `followDocumentLinks` | Also extract the documents linked on a web page | `false` |

```json
{
  "sources": [{ "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" }]
}
```

### Output

One row per document. Real result for the IRS Form W-9 (October 2026; `text` and `pages` shortened):

```json
{
  "source": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "status": "ok",
  "fileType": "pdf",
  "pageCount": 6,
  "title": "Form W-9 (Rev. March 2024)",
  "author": "SE:W:CAR:MP",
  "language": "en",
  "characters": 37694,
  "ocrPages": 0,
  "text": "W-9\nRequest for Taxpayer\nForm Give form to the\n(Rev. March 2024) Identification Number and Certification requester. …",
  "pages": [
    { "page": 1, "text": "W-9\nRequest for Taxpayer …", "ocr": false },
    { "page": 2, "text": "Form W-9 (Rev. 3-2024) Page 2\nmust obtain your correct taxpayer identification number (TIN) …", "ocr": false }
  ],
  "metadata": {
    "subject": "Request for Taxpayer Identification Number and Certification",
    "creator": "Designer 6.5",
    "created": "2024-03-06T08:18:13",
    "modified": "2024-03-06T08:18:13",
    "pageCount": 6
  }
}
```

You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

### Data fields

| Field | Description |
|---|---|
| `text` | The whole document as plain text |
| `pages[].page` / `pages[].text` / `pages[].ocr` | Text of each page, and whether it was read with OCR |
| `pageCount`, `characters` | Size of the document |
| `title`, `author`, `language` | From the document metadata (language is detected from the text) |
| `metadata` | Subject, creator, producer, creation and modification dates |
| `ocrPages` | Pages read with OCR (billed as OCR pages) |
| `status`, `warnings` | `ok` or `error`, and anything worth knowing (for example, no text found) |

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

| Event | Price |
|---|---|
| Run start (per GB of memory) | $0.001 |
| Document processed (any number of pages) | **$0.003** |
| OCR page (only scanned pages without text) | $0.01 |

**1,000 native PDFs cost about $3**, whatever their length. Failed documents are free. Set **Max cost per run** and the Actor stops cleanly at that limit.

### Use it with AI agents (MCP)

Add `https://mcp.apify.com?tools=fguiraud/pdf-text-extractor` to Claude, Cursor or any MCP client and ask: *"Read this contract and list the termination clauses: https://example.com/contract.pdf"*.

Smallest useful input for an agent: `{"sources": [{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"}]}`.

**Agent-friendly input**: common field names such as `url`, `urls`, `startUrls`, `query` or `keywords` are accepted, and an empty input runs a small sample from the input form (with a note in the results) instead of failing.

### Related tools

- [PDF to Markdown Extractor & Document Parser](https://apify.com/fguiraud/document-to-markdown-tables): LLM-ready Markdown, RAG chunks and AI field extraction (invoices, forms), same engine.
- [PDF Table Extractor](https://apify.com/fguiraud/pdf-table-extractor): every table to Excel, CSV and JSON.

### FAQ and limitations

- **Scanned PDFs**: OCR is automatic for pages without text; `ocr: "never"` turns it off, `"always"` forces it.
- **Encrypted PDFs**: enter the password in **PDF password**.
- **Very large documents**: results over 9 MB drop the per-page text first and keep the full text, with a warning.
- Found a problem or need a feature? Open an issue on the **Issues** tab. Replies within 48 hours.

# Changelog

This Actor's version history is a separate document: https://apify.com/fguiraud/pdf-text-extractor/changelog.md

# Actor input Schema

## `sources` (type: `array`):

Document URLs. Supported: PDF (native or scanned), DOCX, XLSX, XLS, PPTX, HTML pages, CSV, TXT and images. Share links from Google Drive, Google Docs/Sheets/Slides, Dropbox, OneDrive/SharePoint and GitHub are converted to downloads automatically (the file must be shared as 'Anyone with the link'). The real file type is detected from the content.

## `base64Files` (type: `array`):

For files that are not reachable by URL, e.g. from an AI agent or a local script: a list of objects {"fileName": "report.pdf", "content": "<base64>"}. A data: URI is also accepted as content. Keep the total input under ~9 MB; use URLs for bigger files.

## `outputs` (type: `array`):

Fields to include for each document. 'text': the whole document as plain text. 'pages': the text of each page (or slide/sheet). 'markdown': LLM-ready Markdown with headings and tables. 'tables': every table as header + rows + CSV. 'chunks': text split into RAG chunks with page numbers.

## `ocr` (type: `string`):

'auto': run OCR only on scanned pages that contain no text (recommended). 'always': OCR every page, even if it has a text layer. 'never': no OCR (images and scanned pages return no text). OCR pages are billed separately.

## `ocrLanguages` (type: `array`):

Languages of the scanned text. Adding more languages is slightly slower.

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

Pages to process, e.g. '1-5, 8'. Applies to PDF pages, PowerPoint slides and Excel sheets. Leave empty for all.

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

Safety limit on pages processed per document.

## `removeHeadersFooters` (type: `boolean`):

Drop lines repeated at the top or bottom of most PDF pages (page numbers, document titles, confidentiality notices) so Markdown and RAG chunks stay clean.

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

Password for encrypted PDFs (applies to all PDFs in the run).

## `followDocumentLinks` (type: `boolean`):

If a source URL is a web page, find links to PDF/DOCX/XLSX/XLS/PPTX/CSV files on it and convert those documents instead (e.g. a reports, filings or publications page). The page itself is not billed.

## `maxLinkedDocuments` (type: `integer`):

Limit for 'Also process documents linked from web pages'.

## `saveFiles` (type: `boolean`):

Save each document's Markdown as a .md file, each table as a .csv file and all tables together as an Excel workbook (.xlsx, one sheet per table) in the run's key-value store; the result includes their download links (handy without code: open the link, get the file).

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

Documents larger than this are skipped (not billed).

## `failOnError` (type: `boolean`):

Mark the run as FAILED when a document cannot be processed or yields no text. Useful for pipelines and monitoring. Successfully processed documents are still returned (and billed).

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

How many documents are processed at the same time.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "outputs": [
    "text",
    "pages"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPages": 500,
  "removeHeadersFooters": true,
  "followDocumentLinks": false,
  "maxLinkedDocuments": 20,
  "saveFiles": false,
  "maxFileSizeMb": 50,
  "failOnError": false,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("fguiraud/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 = { "sources": [{ "url": "https://arxiv.org/pdf/1706.03762" }] }

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

```

## MCP server setup

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