# PDF Text Extractor — fast PDF to text & JSON, per page (`amanatools/pdf-text-extractor`) Actor

Extract clean plain text from PDF files: whole document plus every page separately, in true reading order — multi-column layouts and RTL (Arabic) handled. No OCR overhead, no API keys. Pay per page delivered; scanned pages are detected, reported and never billed.

- **URL**: https://apify.com/amanatools/pdf-text-extractor.md
- **Developed by:** [Dos](https://apify.com/amanatools) (community)
- **Categories:** Developer tools, AI
- **Stats:** 3 total users, 2 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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF Text Extractor — fast PDF to text & JSON, per page

Give it PDF links; get back clean plain text — the whole document and every
page separately — in **true reading order**. Multi-column pages are read
column by column, not welded line by line across the gutter. Arabic and other
right-to-left text keeps its direction. No OCR overhead, no API keys, no
subscription.

Built for AI agents, RAG pipelines, and anyone who needs the text out of a
PDF without ceremony.

### What you get

One dataset item per input PDF:

```json
{
  "url": "https://example.com/report.pdf",
  "status": "ok",
  "n_pages_in_document": 12,
  "n_pages": 12,
  "n_scanned_pages": 0,
  "script": "latin",
  "n_words": 4816,
  "n_chars": 31220,
  "text": "Full document text, pages joined with \f ...",
  "pages": [
    {
      "page": 1,
      "status": "ok",
      "scanned": false,
      "n_words": 402,
      "n_columns": 2,
      "text": "Page text in reading order ..."
    }
  ]
}
```

Turn on **Include spatial layout rendering** to also get `text_layout` per
page — the page reproduced on a character grid (`pdftotext -layout` style),
which preserves tables without ruling lines, forms and diagram labels.

### What it does well

- **Reading order on multi-column pages.** Column gutters are detected from
  the page's whitespace geometry (up to 3 columns), full-width headings
  split the page into stripes, and each column is read top to bottom.
- **Right-to-left text.** Arabic lines are assembled right-to-left; Persian
  and Urdu ZWNJ orthography is preserved, not stripped.
- **Honest scanned-page handling.** A page with no usable digital text layer
  is flagged `"scanned": true` instead of silently returning empty text —
  and it is **not billed**. For scanned documents, use the sibling actor
  [PDF OCR Extractor](https://apify.com/amanatools/pdf-ocr-extractor)
  (Arabic + English OCR built in).
- **Unicode hygiene.** NFC normalization, zero-width and bidi control
  characters removed, exotic spaces unified — text that is safe to compare,
  index and embed.

### Pricing — pay only for delivered text

| Event | Price | Charged when |
|---|---|---|
| `document-processed` | $0.004 | a PDF delivered at least one page of text |
| `text-page` | $0.0004 | per page that actually carried text |

A 10-page report costs $0.008. And the billing rule is deliberate: **failed
downloads, password-protected files, empty pages and scanned pages are never
billed — not even the per-document fee.** If you got no text, you pay
nothing.

Your cost ceiling per document = $0.004 + $0.0004 × *Max pages per document*
(default 100).

### Input

| Field | Default | Notes |
|---|---|---|
| `pdf_urls` | — | up to 100 direct PDF links per run |
| `pages` | `all` | `'1-5'`, `'1,3,7-9'` supported |
| `preserve_layout` | `false` | adds `text_layout` per page |
| `max_pages_per_document` | `100` | hard cost/pages cap per PDF |
| `include_failed_documents` | `true` | failed docs appear with status + error |

### Limits, stated plainly

- Digital text layer only — **no OCR in this actor.** Scanned pages are
  detected and flagged; [PDF OCR Extractor](https://apify.com/amanatools/pdf-ocr-extractor) reads them.
- PDFs up to 50 MB, 100 URLs per run, up to 1000 pages per document.
- Password-protected PDFs are reported as errors (and not billed).

### The family

| Actor | Use it for |
|---|---|
| **PDF Text Extractor** (this one) | fast clean text from digital PDFs |
| [PDF OCR Extractor](https://apify.com/amanatools/pdf-ocr-extractor) | scanned/image PDFs, Arabic + English OCR, bounding boxes |
| [PDF Table Extractor](https://apify.com/amanatools/pdf-table-extractor) | tables as `{headers, rows}` JSON |
| [Doc to Markdown](https://apify.com/amanatools/doc-to-markdown) | documents into LLM-ready Markdown |

### Issues and requests

Open an issue on the actor's Issues tab — I read all of them.

# Actor input Schema

## `pdf_urls` (type: `array`):

Direct links to the PDF files to process (up to 100 per run).

## `pages` (type: `string`):

Which pages to read: 'all', a range like '1-5', or a list like '1,3,7-9'.

## `preserve_layout` (type: `boolean`):

Also return `text_layout` per page — the page reproduced on a character grid ('pdftotext -layout' style). Useful for tables without ruling lines and forms; off by default to keep items small.

## `max_pages_per_document` (type: `integer`):

Hard cap on pages read per PDF — this is also your cost ceiling per document: max spend = $0.004 + $0.0004 x this number. Text-layer reading is fast, so the default is generous.

## `include_failed_documents` (type: `boolean`):

If enabled, documents that fail to download or yield no text still appear in the dataset with their status and error.

## Actor input object example

```json
{
  "pdf_urls": [
    "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
  ],
  "pages": "all",
  "preserve_layout": false,
  "max_pages_per_document": 100,
  "include_failed_documents": true
}
```

# Actor output Schema

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

Default dataset: one item per PDF with url, status, page count, full text, per-page text and scanned-page flags.

# 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 = {
    "pdf_urls": [
        "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("amanatools/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 = { "pdf_urls": ["https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("amanatools/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 '{
  "pdf_urls": [
    "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
  ]
}' |
apify call amanatools/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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