# PDF Text Extractor — text, metadata & page count from PDF URLs (`openregistry/pdf-text-extractor`) Actor

Extract clean text from PDF files by URL, per document or per page, with title, author, dates and page count. Ready for search, RAG and LLM pipelines. Scanned pages without text are not charged. Pay per page.

- **URL**: https://apify.com/openregistry/pdf-text-extractor.md
- **Developed by:** [Mahé Perrin](https://apify.com/openregistry) (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

$0.50 / 1,000 pdf page extracteds

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 — text, metadata & page count from PDF URLs

Give it links to PDF files, get back clean text and metadata in a table: one row per document or one row per page. Built on Mozilla's pdf.js engine (the one inside Firefox), so it reads the text layer of virtually any digital PDF: reports, invoices, contracts, papers, forms, manuals.

### What it is for

- **RAG and LLM pipelines**: per-page text with page numbers, ready to chunk, embed and cite.
- **Search and indexing**: make a pile of PDFs searchable in your database or Elasticsearch.
- **Document monitoring**: run on a schedule against regulatory filings, price lists or tenders and diff the text.
- **Data entry**: pull the text of invoices or forms into a sheet before parsing it with your own rules.
- **Inventory**: page counts, titles, authors and creation dates of a document library.

Works from Make, Zapier, n8n or the API: send the URLs, read the dataset.

### Input example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "outputMode": "document",
  "maxPagesPerFile": 2000,
  "maxFileSizeMb": 50
}
```

- `urls` — direct public links (the link must download the PDF, not open a viewer page).
- `outputMode` — `document` (full text in one row) or `page` (one row per page).
- `maxPagesPerFile` — only the first pages are read beyond this, you control the cost.
- `maxFileSizeMb` — size limit per file (1 to 200 MB, default 50).
- `normalizeWhitespace` — collapse repeated spaces and blank lines (on by default).

### Output example (real result, text shortened)

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileName": "fw9.pdf",
  "fileSizeBytes": 140815,
  "pageCount": 6,
  "pagesExtracted": 6,
  "pagesWithText": 6,
  "likelyScanned": false,
  "charsCount": 37693,
  "wordsCount": 6278,
  "truncated": false,
  "title": "Form W-9 (Rev. March 2024)",
  "subject": "Request for Taxpayer Identification Number and Certification",
  "creator": "Designer 6.5",
  "createdAt": "2024-03-06T13:18:13.000Z",
  "pdfVersion": "1.7",
  "text": "Form W-9(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification\n...",
  "error": null
}
```

In `page` mode each row has `page`, `pageCount`, `hasText`, `charsCount`, `wordsCount`, `title`, `author` and `text`.

### Honest limits

- **No OCR.** Scanned PDFs (images of pages) have no text layer. Such pages come back empty, the document is flagged `likelyScanned: true`, and **those pages are not charged**.
- Password-protected PDFs, broken links, HTML pages and files over the size limit return a row with an `error` message and are **not charged**.
- Text comes out in the order stored in the PDF. Multi-column layouts and tables are usually fine line by line, but complex layouts can interleave; table structure is not rebuilt.
- Files are downloaded once and kept only in memory during the run.

### Privacy

The PDFs you point to are only read to extract their text, which is stored in your own Apify dataset. Only process documents you are allowed to use.

### Pricing

**$0.0005 per page with text** ($0.50 per 1,000 pages). Empty and scanned pages, and files that fail, are free. Set a maximum charge per run in the Apify console: the Actor never goes over it and delivers exactly the pages paid for (the last file is then marked `truncated`).

# Actor input Schema

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

Direct, public links to PDF files (the link must download the file, not open a viewer page). Duplicates are read once.

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

Per page is handy for citations, chunking and RAG. The price is the same.

## `maxPagesPerFile` (type: `integer`):

Only the first pages are read beyond this number, so you control the cost of very long files.

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

Bigger files are skipped with an error row (not charged). Give the run more memory for files above 100 MB.

## `normalizeWhitespace` (type: `boolean`):

Collapse repeated spaces and blank lines. Turn off to keep the raw spacing produced by the PDF.

## Actor input object example

```json
{
  "urls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "outputMode": "document",
  "maxPagesPerFile": 2000,
  "maxFileSizeMb": 50,
  "normalizeWhitespace": true
}
```

# 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 = {
    "urls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("openregistry/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.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("openregistry/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.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call openregistry/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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