# PDF to Text & Markdown - Extract Text from PDF URLs (`ennobling_spray/pdf-to-text`) Actor

Extract text from PDFs by URL: whole document or page by page, with title, author and page count. Fast, no OCR needed for text PDFs. Obeys robots.txt. Pay only per PDF processed.

- **URL**: https://apify.com/ennobling_spray/pdf-to-text.md
- **Developed by:** [Conor Wilson](https://apify.com/ennobling_spray) (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

$2.00 / 1,000 pdfs

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 to Text

Extract the text from PDFs by URL, either as one document or page by page, with title, author and page count. Built for RAG pipelines, search indexing, document review and data entry automation.

**$2 per 1,000 PDFs.** PDFs that fail to download, are blocked, are not really PDFs, or contain only scanned images are returned with the reason and **never charged**.

### Why this one

- **Fast text-layer extraction** with no OCR overhead for the large majority of PDFs, which are generated digitally.
- **Per-page output** when you need to cite or chunk by page.
- **Clean text.** Whitespace collapsed and page order kept.
- **Safe limits.** Cap pages per PDF and file size so a giant document can't run up your bill.
- **Honest failures.** Scanned-image PDFs are detected and reported as "no extractable text" instead of being billed for empty output.

### Quick start

```json
{
    "urls": [{ "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" }],
    "perPage": true,
    "maxPages": 0
}
```

### Output

| Field | Description |
| --- | --- |
| `text` | All extracted text |
| `pages` | Array of page texts, if `perPage` is on |
| `pageCount`, `pagesExtracted`, `wordCount` | Document size |
| `title`, `author` | PDF metadata when present |
| `fileSizeBytes`, `url`, `finalUrl`, `fetchedAt` | Download details |
| `ok`, `error` | Whether extraction succeeded, and why not |

### Input options

| Option | Default | Notes |
| --- | --- | --- |
| `urls` | required | PDF URLs |
| `perPage` | `false` | Also return per-page text |
| `maxPages` | `0` | Only the first N pages (0 = all, up to 2,000) |
| `maxFileMb` | `50` | Skip larger files, not charged |
| `maxConcurrency` | `3` | Parallel downloads |

### Limits and good use

- Scanned PDFs (images of text) need OCR, which is not included. They are reported and not charged.
- Password-protected PDFs cannot be read.
- The actor fetches only what robots.txt allows for its user agent `WilsDataTools`, and never bypasses logins or bot protection.
- You are responsible for having the right to process the documents you submit.

### Pricing

Pay per event: one event per PDF successfully extracted, whatever its page count up to your `maxPages` cap.

# Actor input Schema

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

PDF URLs. Each successfully extracted PDF is one billable event.

## `perPage` (type: `boolean`):

Also return an array with the text of each page.

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

Only extract the first N pages (0 = all, up to 2,000).

## `maxFileMb` (type: `integer`):

Skip PDFs larger than this (not billed).

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

How many PDFs to process at once.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ],
  "perPage": false,
  "maxPages": 0,
  "maxFileMb": 50,
  "maxConcurrency": 3
}
```

# Actor output Schema

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

Extract text from PDFs by URL: whole document or page by page, with title, author and page count.

# 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": [
        {
            "url": "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("ennobling_spray/pdf-to-text").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": [{ "url": "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("ennobling_spray/pdf-to-text").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": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ]
}' |
apify call ennobling_spray/pdf-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ennobling_spray/pdf-to-text"
        }
    }
}
```

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/NTpOfLNCehPuh2NrL/builds/oEaTAKvTdCsf1vXoA/openapi.json
