# PDF Text Extractor - Bulk PDF to Text, Metadata & Search (`paperlinenstudio/pdf-text-extractor`) Actor

Extract text and metadata from PDFs in bulk: give PDF URLs or web pages that link to PDFs. Get full text or one item per page, title, author, dates, page and word counts, keyword hits with page numbers and snippets, and a flag for scanned PDFs. Ideal for RAG, LLM and research pipelines.

- **URL**: https://apify.com/paperlinenstudio/pdf-text-extractor.md
- **Developed by:** [Paper & Linen Studio](https://apify.com/paperlinenstudio) (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 usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 – Bulk PDF to Text, Metadata & Keyword Search

Turn any list of PDF links into clean, searchable text. Paste **PDF URLs** or **web pages that link to PDFs** (report archives, download pages, investor-relations pages). You get one dataset row per PDF, or one row per page:

- **Full text** from the PDF's text layer, cleaned up: hyphenated line breaks are joined, soft hyphens removed and whitespace collapsed
- **Per-page output** (`outputMode: "page"`) with page numbers, ready for **RAG chunking, embeddings and citations**
- **Metadata**: title, author, subject, keywords, creator/producer, creation and modification date, page count, file size, encryption
- **Keyword search**: words, phrases or `re:` regular expressions, with **page number and a text snippet** for every hit and a count per term. Optionally return only PDFs that contain a term.
- **Scanned-PDF detection**: `likelyScanned: true` when the PDF has (almost) no text layer, so you know which files need OCR
- **PDF discovery**: give a web page and the PDFs it links to are found automatically. You can limit them to the same site and cap how many are taken per page.

It needs no browser, no API key and no proxy. Large files are streamed with a size limit, and you can read only the first N pages of very long reports.

### What you can use it for

- **RAG and LLM pipelines**: feed reports, manuals, papers and policies into a vector database, page by page with source and page number
- **Research and monitoring**: find every PDF on a downloads page that mentions "CO2", "Lieferkette" or a competitor, and see where it appears
- **Procurement and tenders**: extract tender documents and search them for deadlines, CPV codes or requirements
- **Finance and investor relations**: pull annual and sustainability reports, then search for key figures and terms
- **Document inventories**: list titles, authors, dates and page counts of all PDFs a website publishes, and spot outdated or scanned files

### Input

| Field | Description |
|---|---|
| `urls` | PDF links or web pages that link to PDFs |
| `searchTerms` | Optional words/phrases (case-insensitive, whole words) or `re:` regex |
| `onlyMatching` | Only return PDFs (or pages) with at least one hit. Skipped PDFs are not charged. |
| `outputMode` | `document` (one item per PDF, default) or `page` (one item per page) |
| `findPdfLinks`, `sameSiteOnly`, `maxPdfsPerPage` | PDF discovery on web pages (default: on, all sites, 20 per page) |
| `maxPagesPerPdf` | Read only the first N pages (0 = all) |
| `maxTextLength` | Truncate `text` per item (default 100,000 characters; `textLength` always shows the full length) |
| `cleanText` | Text clean-up (default `true`) |
| `maxFileSizeMb`, `maxItems`, `maxConcurrency`, `timeoutSecs` | Limits |
| `respectRobotsTxt` | Honour robots.txt for scanned pages and the PDFs found on them (default `true`) |

```json
{
  "urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf", "https://www.irs.gov/forms-pubs/about-form-w-9"],
  "searchTerms": ["backup withholding", "re:\\bTIN\\b"],
  "maxPdfsPerPage": 5
}
```

### Output (real example, shortened)

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "sourcePage": null,
  "fileName": "fw9.pdf",
  "fileSizeBytes": 140815,
  "pageCount": 6,
  "pagesExtracted": 6,
  "encrypted": false,
  "title": "Form W-9 (Rev. March 2024)",
  "author": "SE:W:CAR:MP",
  "subject": "Request for Taxpayer Identification Number and Certification",
  "creator": "Designer 6.5",
  "createdAt": "2024-03-06T08:18:13",
  "modifiedAt": "2024-03-06T08:18:13",
  "likelyScanned": false,
  "emptyPages": 0,
  "text": "Form W-9\n(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification\nDepartment of the Treasury …",
  "textLength": 37692,
  "wordCount": 6278,
  "textTruncated": true,
  "matchedTerms": ["backup withholding"],
  "matchCounts": {"backup withholding": 33},
  "matches": [
    {"term": "backup withholding", "page": 1, "snippet": "appropriate box. The TIN provided must match the name given on line 1 to avoid backup withholding. For individuals, this is generally your social security number (SSN). However,"}
  ],
  "error": null,
  "durationMs": 91,
  "extractedAt": "2026-11-03T13:52:12+00:00"
}
```

In `page` mode each item has `pageNumber`, `text`, `textLength`, `wordCount` and the `matches` on that page. Failed downloads are returned with an `error` (e.g. `HTTP 404`, `Not a PDF`, `PDF is password-protected`, `File larger than maxFileSizeMb`). The key-value store record `SUMMARY` holds run totals.

### Limitations

- **No OCR.** Scanned PDFs without a text layer return little or no text and are flagged with `likelyScanned: true`.
- Reading order follows the PDF's internal text order. Multi-column layouts and tables come out as plain text, not as structured tables.
- Password-protected PDFs are skipped. PDFs that are only encrypted against editing or printing are read normally.
- PDFs behind a login, cookie wall or JavaScript-only download button can't be reached. Use direct file links.
- `matches` is capped at 500 snippets per PDF; `matchCounts` always has the full count.

### Pricing

Free to use. You only pay for the Apify platform usage of your run, which is low because no browser is used.

***

### Deutsch: Kurzbeschreibung

**PDF Text Extractor**: Text und Metadaten aus beliebig vielen PDFs extrahieren. Du gibst PDF-Links oder Webseiten an, auf denen PDFs verlinkt sind.

- Volltext oder ein Datensatz pro Seite (ideal für RAG/KI)
- Titel, Autor, Datum, Seitenzahl
- Stichwortsuche mit Seitenzahl und Textausschnitt
- Erkennung gescannter PDFs ohne Textebene

Kein Browser, kein API-Key. Ideal für Ausschreibungen, Geschäftsberichte, Handbücher und Recherche.

# Actor input Schema

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

Direct links to PDF files, or web pages that link to PDFs (e.g. a report archive or a downloads page). For web pages the linked PDFs are found and extracted (see 'Find PDFs linked from web pages'). Duplicates are removed.

## `searchTerms` (type: `array`):

Words or phrases to find in each PDF (case-insensitive, whole words). Each hit is returned with the page number and a text snippet. Prefix with re: for a regular expression, e.g. re:\d{2}.\d{2}.\d{4}.

## `onlyMatching` (type: `boolean`):

Skip PDFs (or pages in page mode) without any search-term hit. Skipped PDFs are not charged.

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

Return one dataset item per PDF, or one item per page with its page number.

## `findPdfLinks` (type: `boolean`):

If a URL is a web page instead of a PDF, extract the PDFs it links to (links ending in .pdf, embeds and iframes).

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

When scanning a web page, ignore PDF links pointing to other domains.

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

Maximum number of linked PDFs to extract from each web page.

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

Only read the first N pages of each PDF (0 = all pages). Useful for huge reports where only the summary matters.

## `maxTextLength` (type: `integer`):

Truncate the text field to this many characters (0 = no limit). The full length is still reported in textLength.

## `cleanText` (type: `boolean`):

Join hyphenated line breaks, remove soft hyphens and collapse repeated spaces and blank lines.

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

Skip PDFs larger than this.

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

Stop after this many PDFs (successful + failed).

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

How many PDFs are downloaded in parallel.

## `timeoutSecs` (type: `integer`):

Timeout for each download.

## `respectRobotsTxt` (type: `boolean`):

Do not scan web pages or download linked PDFs that the site's robots.txt disallows. Direct PDF URLs you enter are always fetched.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "searchTerms": [],
  "onlyMatching": false,
  "outputMode": "document",
  "findPdfLinks": true,
  "sameSiteOnly": false,
  "maxPdfsPerPage": 20,
  "maxPagesPerPdf": 0,
  "maxTextLength": 100000,
  "cleanText": true,
  "maxFileSizeMb": 50,
  "maxItems": 1000,
  "maxConcurrency": 5,
  "timeoutSecs": 60,
  "respectRobotsTxt": true
}
```

# Actor output Schema

## `items` (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 = {
    "urls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "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("paperlinenstudio/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.irs.gov/pub/irs-pdf/fw9.pdf",
        "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("paperlinenstudio/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.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call paperlinenstudio/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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