# PDF Text Extractor API — Full Text, Per-Page Text & Metadata (`pappy-dev/pdf-text-extractor`) Actor

Extract text and metadata from PDF URLs: one row per document or one row per page for RAG chunking. Page ranges, encrypted PDFs without a password, clear skip messages. No browser, no proxy. Pay only for pages with text.

- **URL**: https://apify.com/pappy-dev/pdf-text-extractor.md
- **Developed by:** [Backyard Tools](https://apify.com/pappy-dev) (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 with text 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 API — Full Text, Per-Page Text & Metadata

Give the actor PDF links, get back the text and the document metadata as clean structured data —
one row per document, or one row per page for RAG / LLM chunking. Fast text-layer extraction with
[pypdfium2](https://pypi.org/project/pypdfium2/) (Google's PDFium, the PDF engine inside Chrome):
no browser, no proxy, no OCR guesswork.

You only pay for pages that actually contained text — blank and scanned-image pages are free.

### Pdf text extractor API — input

Each line of `targets` is one PDF URL, optionally with options in front:

| Line | Returns |
|---|---|
| `https://example.com/report.pdf` | 1 row: the whole document's text (pages marked `--- Page N ---`) |
| `pages:1-5 https://example.com/report.pdf` | only pages 1–5 (`1-3,7` also works) |
| `perpage: https://example.com/report.pdf` | 1 row per page (`page_number` set) |
| `perpage:pages:2-4 https://example.com/report.pdf` | both |

```json
{
  "targets": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "perpage:pages:1-2 https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "maxItems": 100
}
```

`maxItems` is the maximum number of rows (documents, or pages in `perpage:` mode).

### Pdf text extractor API — output fields

| Field | |
|---|---|
| `url`, `file_name`, `file_size_bytes` | the file you gave |
| `page_count` | pages in the document |
| `page_number` | page of this row (`perpage:` mode), otherwise empty |
| `pages_extracted` | pages read for this row |
| `text` | extracted text, whitespace tidied |
| `text_chars`, `word_count` | size of the text |
| `has_text_layer` | `false` means the pages are images (a scan) — this actor does not OCR |
| `title`, `author`, `subject`, `keywords`, `creator`, `producer` | document metadata, when present |
| `creation_date`, `modification_date` | ISO-style dates from the PDF metadata |
| `is_encrypted` | the PDF was encrypted (only files that open without a password are read) |
| `text_truncated` | text was cut at 4 MB for one row — use `perpage:` for very large files |
| `failed_pages` | pages that could not be read (the rest of the document is still returned) |

Files that cannot be used (not a PDF, HTTP error, password-protected, damaged, over 100 MB)
are skipped with a clear message in the log and **are not charged**.

### Tested (2026-11-18)

| File | Result |
|---|---|
| IRS Form W-9 (6 pages) | 37,679 characters; `pages:1-2` and `perpage:` modes return the same text per page |
| IRS Publication 17 (142 pages, 3.1 MB) | 952,773 characters, 0 failed pages, about 2 seconds including the download |
| IRS Form 1040 Instructions (126 pages, 4.4 MB) | 601,446 characters, 0 failed pages, about 2 seconds including the download |
| AES-256 encrypted PDF without a user password | read (`is_encrypted: true`) |
| password-protected PDF / damaged PDF / HTML saved as `.pdf` / HTTP 404 | skipped with a message, 0 rows |
| two blank pages (no text layer) | `has_text_layer: false`, 0 pages charged |

### Use cases

- **RAG and LLM pipelines**: per-page text ready for chunking and embedding
- **Document processing**: pull text out of reports, filings, manuals and papers in bulk
- **Search and archiving**: index the text and metadata of a PDF library
- **Monitoring**: re-read a published PDF on a schedule and compare the text

### Limits

- No OCR: scanned PDFs return `has_text_layer: false` and empty text
- Text-layer order follows the PDF itself; complex multi-column layouts may interleave
- Use files you have the right to process; the actor downloads exactly the URLs you give and nothing else

### Pricing

Pay per event: **$0.50 per 1,000 pages with text**. Pages without text are free.

# Actor input Schema

## `targets` (type: `array`):

One PDF URL per line. Optional prefixes: pages:1-5 (page range), perpage: (one row per page), e.g. perpage:pages:2-4 https://example.com/file.pdf

## `maxItems` (type: `integer`):

Maximum number of items to collect in one run.

## Actor input object example

```json
{
  "targets": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "maxItems": 10
}
```

# Actor output Schema

## `items` (type: `string`):

Every collected record (type=item)

## `overview` (type: `string`):

Link to this run's page: status, log and dataset

# 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 = {
    "targets": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    ]
};

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

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

```

## MCP server setup

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