# Extract Text From PDF: text per page for LLMs and RAG (`steadydata/pdf-text-extractor`) Actor

Extract text from PDF files by URL, up to 200 files per run: one row per page (or one per file) with the text, page count, title, author, dates, producer and file size, plus whether the page has a text layer. Optional: tables as cells and as Markdown. Pay per page delivered.

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

## Pricing

from $1.95 / 1,000 page extracteds

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

## Extract Text From PDF: text per page for LLMs and RAG

Extract text from PDF files by URL, up to 200 files per run: one row per page (or one per file) with the text, page count, title, author, dates, producer and file size, plus whether the page has a text layer. Optional: tables as cells and as Markdown. Pay per page delivered.

### Why this scraper

- **Only delivered results are charged.** Inputs that fail come back as clear error
  records at no cost.
- Pure Python parsing, no browser and no OCR engine: a 15-page research paper comes back page by page in a few seconds. Measured on the platform: two files, six pages, for a hundredth of a cent.
- One row per page (or one per file), with the character count and a `hasTextLayer` flag per page, so scanned pages show up as exactly that instead of silently empty. The document's own metadata rides along: title, author, subject, creation and modification dates as ISO timestamps, producer, file size, encryption flag. Every URL is checked against its host's robots.txt before the file is fetched, and files above 50 MB are refused for free.
- **Tables as Markdown, at the same price.** Switch on `extractTables` and every page row also carries its ruled tables, as clean rows of cells and as a Markdown table you can drop straight into an LLM prompt or a RAG chunk. Merged cells and headers spread over several lines are folded into one header row and real columns, instead of the dozens of empty columns a raw table parser returns.

### Who this is for

Paste direct PDF links in `urls` (up to 200 per run). Leave `mergePages` off for one row per page, or switch it on for one row per file with all pages joined (that row is charged as the number of pages it holds, the same as per page). `maxPagesPerFile` caps the cost per file. Every row carries the URL, file name, page number, page count, text, character count, text-layer flag, title, author, subject, dates, producer, file size and encryption flag.

### Who this is not for

This reads the text layer; a scanned PDF (images of pages) comes back with empty text and `hasTextLayer` false on every page, because there is nothing to read without OCR. Title, author and subject are whatever the producing software wrote into the file, and most files carry no title or subject at all (a research paper from LaTeX has a producer but no author field). Reading order follows the PDF's internal order, which can differ from the visual layout in multi-column documents. Password-protected files and pages that pypdf cannot parse are reported, not charged. Table extraction finds tables drawn with lines; a table laid out with spaces alone, without ruling, stays in the page text and does not appear in `tables`. That includes most tables in typeset research papers, which use only a few horizontal rules: their content is in `text`, not in `tables`.

### Input fields

| Field | Type | Required or default | What it does |
|---|---|---|---|
| `urls` | list of text | required | One URL per row, up to 200. Direct links to PDF files. |
| `mergePages` | true/false | false | Off: one row per page. On: one row per file with all pages joined; that row is charged as the number of pages it holds. |
| `maxPagesPerFile` | number | 200 | Cost ceiling per file, from the first page. |
| `extractTables` | true/false | false | On: every page row also carries the ruled tables on that page, as rows of cells and as a Markdown table. Slower on long files; the price stays per page. |

### Input example

```json
{
    "urls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ],
    "mergePages": false,
    "maxPagesPerFile": 200
}
```

### Output example

| Field | Type | What it holds | Example |
|---|---|---|---|
| `url` | text | The page or file this row is about. | `https://arxiv.org/pdf/1706.03762` |
| `fileName` | text | The file name from the link or from the response header. | `1706.03762` |
| `page` | number | The page number this row comes from; one row per page. | `1` |
| `pageCount` | number | How many pages the PDF holds in total. | `15` |
| `text` | text | The plain text, without markup, ready to search or feed to a model. | `1 Introduction Recurrent neural networks, long short-term...` |
| `chargedReads` | number |  |  |
| `characters` | number | How many characters of text this page yielded. | `2855` |
| `hasTextLayer` | true/false | True when the page carries real text; false means a scan, where you need OCR instead. | `True` |
| `title` | text | The title in the PDF's own properties; often empty or the name of the program that made it. |  |
| `author` | text | The author the source names; empty when it names none. |  |
| `subject` | text | The subject in the PDF's properties. |  |
| `createdAt` | text | When the PDF was created, according to its own properties. | `2024-04-10T21:11:43Z` |
| `modifiedAt` | text | When it was last changed, according to its own properties. | `2024-04-10T21:11:43Z` |
| `producer` | text | The program that produced the PDF, which often says how it was made. | `pdfTeX-1.40.25` |
| `fileBytes` | number | The size of the file in bytes. | `2215244` |
| `encrypted` | true/false | True when the PDF is protected; a protected file yields no text. | `False` |
| `tables` | list |  |  |
| `tablesMarkdown` | text |  |  |

Error codes: `INVALID_URL`, `ROBOTS_DISALLOWED`, `NOT_A_PDF`, `FETCH_FAILED`, `TOO_LARGE`, `BLOCKED`.

One delivered row looks like this:

```json
{
  "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
  "fileName": "dummy.pdf",
  "pageCount": 1,
  "title": null,
  "author": "Evangelos Vlachogiannis",
  "subject": null,
  "createdAt": "2007-02-23T17:56:37",
  "modifiedAt": null,
  "producer": "OpenOffice.org 2.1",
  "fileBytes": 13264,
  "encrypted": false,
  "page": 1,
  "text": "Dummy PDF file",
  "characters": 14,
  "hasTextLayer": true,
  "status": "ok"
}
```

### Related actors from steadydata

- [sitemap-urls](https://apify.com/steadydata/sitemap-urls): find every PDF a site lists in its sitemap
- [url-status-redirect-checker](https://apify.com/steadydata/url-status-redirect-checker): check which PDF links still answer
- [google-patent-details](https://apify.com/steadydata/google-patent-details): patent texts without the PDF
- Used together with sitemap-urls and webpage-to-markdown in a recipe: Feed a RAG pipeline with clean page text.

### Pricing

Pay per event: one `page-extracted` event per delivered result. No charge for inputs
that fail, no separate platform-usage surcharge.

**Free Apify plan:** this actor delivers up to 25 rows per run for accounts on the Apify free
plan, and then stops with a message. That limit is set by us, not by Apify. It exists so the
actor keeps paying for itself for the people who do pay. Any paid Apify plan runs it at full
size, billed per delivered row, with failed rows never charged.

**Reviews:** if this actor saves you time, a short review on this page is the one thing that
helps most. Ratings are what other buyers look at first, and we have no other way to ask.

### Use with AI agents

AI assistants such as Claude, ChatGPT or Cursor can run this actor through Apify's own MCP server. Ask for the actor `steadydata/pdf-text-extractor` by its full name, so the assistant does not pick a different one, and start from this minimal input:

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ]
}
```

The assistant can read the price per event from the Pricing section above before the first paid run. Failed input comes back as an error row, as described above.

### FAQ

**Does it do OCR?** No. It extracts the existing text layer; the `hasTextLayer` flag tells you which pages would need OCR. For scanned PDFs, send the same URL to [Image OCR Text Extractor](https://apify.com/steadydata/image-ocr-text): it renders every page and reads it, up to 50 pages per file.

**Can I get the whole document as one text?** Yes, switch on `mergePages`; the joined row is charged per page it holds, so the price is the same as one row per page.

**What about very large files?** Files above 50 MB are refused as a free error row; use `maxPagesPerFile` to cap long documents.

**Where do the URLs come from?** Any direct PDF link: your own site, the Sitemap URLs actor below, a search result. A page that returns HTML instead of a PDF is a free `NOT_A_PDF` error row.

**Do I pay for a file that fails?** No. Only delivered pages (or merged files) are charged.

**Is personal data collected?**
Only what is in the PDFs you send: the actor returns their text per page and keeps nothing after the run. Send only files you are allowed to process.

**What do the fields mean?**
`page` is 1-based, or 0 for a merged file; `characters` counts the cleaned text; `createdAt` and `modifiedAt` are the PDF info dates as ISO timestamps without a time zone.

**What happens when the source changes?**
Sources change from time to time; that is the nature of this work. The actor is
monitored daily and fixed fast, and while it is broken you are not charged, because
only delivered results cost anything.

**Can I call it from my own code, like an API?**
Yes. Every run is available through the Apify API: start it with one HTTP request, then read
the results as JSON, CSV or Excel from the dataset endpoint, or use the official Python and
JavaScript clients. The input is the same JSON as in the input example above, so a scheduled
script, a Make or Zapier step or an AI agent can call it without any changes.

# Changelog

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

# Actor input Schema

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

One URL per row, up to 200. Direct links to PDF files.

## `mergePages` (type: `boolean`):

Off: one row per page. On: one row per file with all pages joined; that row is charged as the number of pages it holds.

## `maxPagesPerFile` (type: `integer`):

Cost ceiling per file, from the first page.

## `extractTables` (type: `boolean`):

On: every page row also carries the ruled tables on that page, as rows of cells and as a Markdown table. Slower on long files; the price stays per page.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "mergePages": false,
  "maxPagesPerFile": 200,
  "extractTables": false
}
```

# Actor output Schema

## `results` (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://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadydata/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://arxiv.org/pdf/1706.03762"] }

# Run the Actor and wait for it to finish
run = client.actor("steadydata/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://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call steadydata/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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