# PDF Text Extractor: PDF to Text, Metadata, Emails & Links (`davidcastro/pdf-text-extractor`) Actor

Extract text from PDF links or from every PDF linked on a web page. Get the full text per document or per page, page ranges, title, author, dates, page count, file size, plus emails and links found inside. Export to JSON, CSV or Excel.

- **URL**: https://apify.com/davidcastro/pdf-text-extractor.md
- **Developed by:** [David Castro](https://apify.com/davidcastro) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $15.00 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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: PDF to Text, Metadata, Emails & Links

Turn PDF files into clean text you can search, analyze or feed to AI tools. Give it direct PDF links, or give it a web page such as a reports, filings or downloads page and it reads every PDF linked there. Each PDF comes back with its full text, the document metadata (title, author, subject, creation and modification dates, page count, file size) and the email addresses and links written inside it. You can also get one row per page, choose page ranges, and filter which links to follow.

### What you get

| Field | Example |
|---|---|
| `url`, `fileName` | https://www.irs.gov/pub/irs-pdf/fw9.pdf, fw9.pdf |
| `title`, `subject`, `author` | Form W-9 (Rev. March 2024), Request for Taxpayer Identification Number and Certification, SE:W:CAR:MP |
| `creationDate`, `modificationDate` | 2024-03-06T13:18:13.000Z |
| `creator`, `producer`, `pdfVersion` | Designer 6.5, Designer 6.5, 1.7 |
| `pageCount`, `pagesExtracted` | 6, 6 |
| `fileSizeBytes` | 140815 |
| `text` | the full text, with line breaks kept |
| `wordCount`, `charCount` | 6306, 37723 |
| `emails`, `urls` | \["phishing@irs.gov", "spam@uce.gov"], \["www.irs.gov/FormW9", "www.irs.gov/EIN"] |
| `page` | page number, in per-page mode |
| `pages` | per-page text and word count, when requested |
| `sourcePage` | the web page where the PDF link was found |

### Inputs

- **PDF links:** direct links to PDF files.
- **Web pages with PDF links:** every PDF linked on each page is read, up to your limit per page. Keep only links containing a word, or only PDFs on the same website.
- **One row per:** document (default) or page.
- **Pages:** a range such as `1-5`, `1,3,7` or `10-`, and a maximum number of pages per PDF.
- **Emails and links:** on by default.
- **Max file size:** larger files are skipped and not charged.

### Example input

```json
{
    "pdfUrls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"],
    "pageUrls": ["https://www.irs.gov/forms-instructions"],
    "maxPdfsPerPage": 20,
    "outputMode": "document",
    "pageRange": "1-10"
}
```

### Example output

```json
{
    "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "fileName": "fw9.pdf",
    "title": "Form W-9 (Rev. March 2024)",
    "author": "SE:W:CAR:MP",
    "subject": "Request for Taxpayer Identification Number and Certification",
    "creationDate": "2024-03-06T13:18:13.000Z",
    "pdfVersion": "1.7",
    "pageCount": 6,
    "pagesExtracted": 6,
    "fileSizeBytes": 140815,
    "wordCount": 6306,
    "emails": ["phishing@irs.gov", "spam@uce.gov"],
    "text": "Form W-9\n(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification\n..."
}
```

### Use cases

- Load reports, papers, manuals and contracts into search indexes, chatbots and AI knowledge bases.
- Collect every annual report, filing or price list published on a company or government page.
- Find contact emails inside brochures, catalogs and directories.
- Track when documents on a page change, using the modification date and word count.

### Limits

Scanned PDFs that contain only images have no text to extract; they come back as a row with an `error` message and are not charged. Password-protected PDFs, files above the size limit and broken links are reported the same way. Text order follows the PDF layout, so multi-column pages read column by column as the PDF stores them.

### Pricing

You pay per PDF delivered, or per page in per-page mode. Failed downloads, scanned PDFs, protected files and error rows are never charged. The run stops when it reaches your maximum results or your spend limit. Free Apify plans get up to 10 results per run.

# Actor input Schema

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

Direct links to PDF files.

## `pageUrls` (type: `array`):

Pages such as a reports, filings or downloads page. Every PDF linked on the page is read.

## `maxPdfsPerPage` (type: `integer`):

How many PDF links to take from each web page.

## `linkFilter` (type: `string`):

Keep only PDF links whose address or link text contains this word, for example "annual-report" or "2025".

## `sameSiteOnly` (type: `boolean`):

Skip PDF links that point to other websites.

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

Total documents (or pages, in per-page mode) to deliver in this run. Free Apify plans are limited to 10 per run.

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

One row per PDF with all its text, or one row per page. In per-page mode every page is a result.

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

Pages to read, such as 1-5, 1,3,7 or 10-. Leave empty for all pages.

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

Stop reading a PDF after this many pages.

## `includePageTexts` (type: `boolean`):

Adds a pages list with the text and word count of each page.

## `extractContacts` (type: `boolean`):

Lists the email addresses and web links written in the PDF.

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

Larger files are skipped and not charged.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "pageUrls": [],
  "maxPdfsPerPage": 50,
  "linkFilter": "",
  "sameSiteOnly": false,
  "maxResults": 20,
  "outputMode": "document",
  "pageRange": "",
  "maxPagesPerPdf": 1000,
  "includePageTexts": false,
  "extractContacts": true,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

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

Document, title, pages and the start of the text.

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

Every field, including full text, emails and links.

# 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": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    ],
    "pageUrls": [],
    "linkFilter": "",
    "maxResults": 20,
    "pageRange": ""
};

// Run the Actor and wait for it to finish
const run = await client.actor("davidcastro/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": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"],
    "pageUrls": [],
    "linkFilter": "",
    "maxResults": 20,
    "pageRange": "",
}

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

```

## MCP server setup

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