# PDF to Text API: Extract Text from PDF URLs for AI and RAG (`loamy_barista/pdf-text-extractor`) Actor

PDF to text API for AI agents and RAG: send PDF URLs, get clean text plus metadata: page count, title, dates, word count and page markers. One row per PDF, no browser, no OCR fees. Pay only for PDFs extracted; failed URLs are free.

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

## Pricing

from $3.50 / 1,000 pdf processeds

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 API: Extract Text from PDF URLs for AI and RAG

A **PDF to text API** for AI agents and RAG pipelines: send **PDF URLs, get clean text** with metadata: page count, title, subject, creation and modification dates, word count and page markers. One row per PDF, ready for LLM prompts, RAG chunking, search indexes or spreadsheets. No browser and no OCR engine, so runs are fast and cheap, and **one flat price per PDF with no per-page fees**.

### What it returns

One row per PDF URL. The same 24 fields on every run, in the same order; missing values are `null`.

| Field | Example (default run) | Notes |
|---|---|---|
| url / finalUrl | `https://www.rfc-editor.org/rfc/rfc9083.pdf` | `finalUrl` after redirects |
| status / error | `ok` / `null` | `error` rows (free) say why a URL failed: `HTTP 404`, `not a PDF`, password-protected, too large |
| fileName / fileSizeBytes | `rfc9083.pdf` / `524826` | |
| pageCount / pagesExtracted | `81` / `81` | `pagesExtracted` is lower when `maxPagesPerPdf` is set |
| emptyPages / likelyScanned | `0` / `false` | `likelyScanned` is true when no page has a text layer (image-only scan) |
| title | `RFC 9083: JSON Responses for the Registration Data Access Protocol (RDAP)` | From the PDF metadata |
| subject / keywords | `This document describes JSON data structures...` | |
| creatorTool / producer | `xml2rfc 3.8.0` / `cairo 1.16.0` | Software that made the file |
| pdfVersion | `1.5` | |
| createdAt / modifiedAt | `2021-06-11T09:35:56Z` | Converted to UTC ISO 8601 |
| isEncrypted | `false` | Files with an empty owner password are still read |
| charCount / wordCount | `104617` / `15999` | |
| text | `--- page 1 ---\nRFC 9083\nJSON Responses for...` | Full text with page markers |
| textTruncated | `false` | True when `maxCharsPerPdf` cut the text |
| scrapedAt | `2026-11-22T22:31:47Z` | |

The default run (IRS Form W-9, RFC 9083, a W3C test file) returns 3 rows: 6, 81 and 1 pages.

### Use cases

- **RAG and AI agents:** feed reports, filings, manuals and papers into a vector store; split on `--- page N ---` to keep page citations.
- **Document monitoring:** schedule a run on a list of PDFs (price lists, policies, forms) and diff the text.
- **Bulk research:** pull text and dates from hundreds of public PDFs into one dataset or spreadsheet.
- **Triage:** `likelyScanned` and `pageCount` tell you which files need OCR before you pay for it elsewhere.

### Pricing

Pay per result: **$0.0035 per PDF extracted**, whatever its page count. 1,000 PDFs = $3.50. URLs that fail (404, not a PDF, too large, password-protected) are listed for free and never charged. Set `maxItems` to cap spend.

### Input

Runs with zero configuration (defaults are filled in). Main field: `pdfUrls`, a list of direct PDF links. Options: `maxPagesPerPdf` (first N pages only), `pageSeparator` (`pageMarker`, `formFeed` or `blankLine`), `maxCharsPerPdf` (truncate long documents to keep LLM context small), `maxFileSizeMb` (default 50), `includeFailedUrls`, `respectRobotsTxt`, `maxConcurrency`, `useApifyProxy`, `maxItems`.

### For AI agents (Apify MCP)

- Call with `{"pdfUrls": ["https://example.com/report.pdf"], "maxCharsPerPdf": 20000}`.
- Output is a flat JSON array; the field list above is exhaustive and stable. Check `status` before reading `text`.
- A run summary is saved to the key-value store record `RUN_SUMMARY` (PDFs extracted, failed URLs with reasons, robots.txt skips).

### Limits

- Text-layer PDFs only. Scanned image PDFs return empty text with `likelyScanned: true`; there is no OCR.
- Reads only the URLs you supply; it does not crawl pages to find PDFs, and it skips URLs whose host's robots.txt disallows them (can be turned off for files you own).
- Password-protected PDFs are reported as failed. Files above `maxFileSizeMb` are skipped.
- Tables come out as plain text in reading order; no table structure.
- The PDF Author field is not returned.

### FAQ

**Is it legal?** It downloads only the public URLs you provide, honors robots.txt by default, and returns document text and technical metadata. You are responsible for having the right to use the documents you process.
**Does it need a login or proxies?** No. It cannot open files behind a login. Proxy is off by default and only needed if a host rate-limits you.
**What if it breaks?** It is health-tested every day and fixed the same day. Open an issue on the Issues tab and it is answered within 24 hours.

### More from Keel Data

Tested daily; failures are fixed the same day.

- [Greenhouse Jobs API: Lever and Ashby Job Board Scraper](https://apify.com/loamy_barista/ats-job-board-scraper)
- [Remote Jobs Aggregator: Himalayas, Jobicy, Arbeitnow, Remote OK](https://apify.com/loamy_barista/remote-jobs-aggregator)
- [Shopify Products JSON Scraper: Full Store Catalog](https://apify.com/loamy_barista/shopify-store-products)
- [Website Tech Stack Detector: CMS, Analytics, Hosting, Pixels](https://apify.com/loamy_barista/website-tech-stack-detector)

If this Actor saved you time, a short review on the Store page helps other builders find it.

# Actor input Schema

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

Direct links to PDF files, one per line, e.g. https://example.com/report.pdf. Links whose response is not a PDF are reported as failed and not charged.

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

Extract only the first N pages of each PDF. 0 = all pages.

## `pageSeparator` (type: `string`):

How page boundaries appear in the text field: '--- page N ---' markers (easy to split for RAG chunking and citations), a form feed character, or a blank line.

## `maxCharsPerPdf` (type: `integer`):

Truncate the text field after this many characters (textTruncated is set to true). 0 = no limit. Useful to keep LLM context small.

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

Skip files larger than this; they are reported as failed and not charged.

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

Add one free row (status 'error' with the reason) for each URL that could not be extracted, so your pipeline knows what failed.

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

Skip URLs that the host's robots.txt disallows for crawlers.

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

How many PDFs to download at once (1-10).

## `useApifyProxy` (type: `boolean`):

Turn on only if a host rate-limits you. Off by default to keep runs cheap.

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

Stop after this many PDFs are extracted. You are charged only for PDFs returned with status 'ok'.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.rfc-editor.org/rfc/rfc9083.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "maxPagesPerPdf": 0,
  "pageSeparator": "pageMarker",
  "maxCharsPerPdf": 0,
  "maxFileSizeMb": 50,
  "includeFailedUrls": true,
  "respectRobotsTxt": true,
  "maxConcurrency": 4,
  "useApifyProxy": false,
  "maxItems": 100
}
```

# Actor output Schema

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

Dataset rows: one record per PDF URL with extracted text and metadata (status 'ok'), plus free 'error' rows for URLs that failed.

# 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",
        "https://www.rfc-editor.org/rfc/rfc9083.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("loamy_barista/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",
        "https://www.rfc-editor.org/rfc/rfc9083.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("loamy_barista/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",
    "https://www.rfc-editor.org/rfc/rfc9083.pdf",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call loamy_barista/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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