# PDF Text Extractor: PDF URL to text for AI and RAG (`fecklesspleb/pdf-text-extractor`) Actor

Turn public PDF URLs into clean text: full document text, optional per-page text, page count, word count and document info. Fast, no browser, low cost per PDF. Great for RAG, LLM pipelines, search indexing and document analysis.

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

Pay per event

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

Turn public PDF URLs into clean text. For each PDF you get the full document text, optional per-page text, page count, word count, PDF version and document info (title, subject, keywords, producer, dates). Fast HTTP download and parsing, no browser. Built for RAG, LLM pipelines, search indexing and document analysis.

**At a glance:** $2.00 per 1,000 PDFs, plus $0.00005 per run start. Pay per result with no subscription, set a maximum cost per run, export to JSON, CSV or Excel, or call it from the Apify API, Make, Zapier or n8n.

### Features

- Bulk: paste hundreds of PDF URLs, processed in parallel.
- Per-page text (`includePages`) for citations and chunking.
- `maxPagesPerPdf` and `maxCharacters` to control output size.
- Clear error rows for broken links, non-PDF files, password-protected files and oversized files.
- `hasTextLayer` tells you when a PDF is a scanned image (OCR is not included).
- Respects robots.txt.

### Input

```json
{
  "pdfUrls": [{"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"}],
  "includePages": true,
  "maxPagesPerPdf": 0
}
```

### Output example

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "finalUrl": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "statusCode": 200,
  "fileSizeBytes": 140815,
  "pageCount": 6,
  "pagesExtracted": 6,
  "wordCount": 6279,
  "hasTextLayer": true,
  "pdfVersion": "1.7",
  "documentInfo": {"title": "Form W-9 (Rev. March 2024)", "subject": "Request for Taxpayer Identification Number and Certification"},
  "text": "Form  W-9\n(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification ...",
  "pages": [{"pageNumber": 1, "text": "..."}],
  "error": null
}
```

### Pricing

Pay per result: **$2.00 per 1,000 PDFs** ($0.002 per PDF), any page count up to the size limit. Plus the standard Apify run start event of $0.00005 per run (the default Apify recommends). Turn off `includeFailedUrls` to pay only for PDFs that were read. Set **Maximum cost per run** and the Actor stops cleanly when it is reached.

### Limits

- Text layer only. Scanned PDFs without a text layer return empty text with `hasTextLayer: false`.
- Layout (tables, columns) is flattened to reading-order text.
- Author and creator names from the document info are not returned.
- On the Apify platform, PDF URLs whose address is private, loopback or link-local (also after a redirect) are not fetched. Their row is free: `error: "not fetched: private, loopback and link-local addresses are not allowed"`.

### Is this legal?

The Actor downloads files that are publicly linked, obeys robots.txt and never logs in. Respect the copyright and terms of the documents you process.

### FAQ

**Can I call it from code or an AI agent?** Yes, through the Apify API, the Apify clients, or Apify's MCP server.

**Can it read local files?** Upload them to any public URL (for example an Apify key-value store record) and pass that URL.

# Changelog

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

# Actor input Schema

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

Direct links to public PDF files.

## `includePages` (type: `boolean`):

Add a pages array with the text of each page (useful for citations and chunking).

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

Read only the first N pages. 0 means all pages. The price is per PDF either way.

## `maxCharacters` (type: `integer`):

Truncate the text field to this length. 0 means no limit.

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

Larger files are skipped with an error row.

## `includeFailedUrls` (type: `boolean`):

Add a row with the error for URLs that fail. Turn off to pay only for PDFs that were read.

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

PDFs downloaded in parallel.

## `maxResults` (type: `integer`):

Cap per run. 0 means no cap.

## Actor input object example

```json
{
  "pdfUrls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ],
  "includePages": false,
  "maxPagesPerPdf": 0,
  "maxCharacters": 0,
  "maxFileSizeMb": 50,
  "includeFailedUrls": true,
  "maxConcurrency": 5,
  "maxResults": 0
}
```

# Actor output Schema

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

No description

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

```

## MCP server setup

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