# PDF Text Extractor - Page by Page, With OCR for Scans (`appdata-labs/pdf-text-extractor`) Actor

Extract text from any list of PDF URLs, one row per page, with title, author and page count. Scanned pages with no text layer are read by OCR in the same run, and each row says how it was read. 20 languages. Pay only for pages with text.

- **URL**: https://apify.com/appdata-labs/pdf-text-extractor.md
- **Developed by:** [Kobkoon Janngam](https://apify.com/appdata-labs) (community)
- **Categories:** Agents, MCP servers, AI
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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

## PDF Text Extractor — page-by-page text, with OCR for scanned pages

**Get the text out of any list of PDFs, one row per page.** Each row also carries the document's title, author and page count. A scanned page has no text layer, so it is read by OCR in the same run, and each row says how its page was read. Built for data pipelines, RAG and AI agents.

**Quick start:** press **Start** with no configuration. It reads three sample PDFs: a 14-page research paper with a text layer, and two scans that need OCR. Then paste your own links.

### Sample output

| fileName | pageNumber | pageCount | method | ocrConfidence | text |
|---|---|---|---|---|---|
| compressed.tracemonkey-pldi-09.pdf | 1 | 14 | text-layer | — | Trace-based Just-in-Time Type Specialization for Dynamic Languages… |
| compressed.tracemonkey-pldi-09.pdf | 2 | 14 | text-layer | — | Hence, recording and compiling a trace speculates that… |
| linn.pdf | 1 | 1 | ocr | 91 | The LinnSequencer · 32 Track MIDI Sequence Recorder… |
| skew.pdf | 1 | 1 | ocr | 91 | The LinnSequencer is a state-of-the-art composition and performance tool… |

These rows come from the default run on 30 October 2026. It read 16 pages with text, 2 of them by OCR.

Every row also carries `pdfUrl`, `status`, `charCount`, `wordCount`, `title`, `author`, `createdAt` and `chunk`/`chunkCount`, plus a `note` when something needs explaining.

### What you can do with it

- **Build a RAG index.** Rows arrive already split into chunks under 3 KB, broken at paragraphs, and each one keeps its page number.
- **Give an AI agent a PDF.** It gets one page at a time instead of a file it cannot open.
- **Digitise scanned archives.** Contracts, invoices, old manuals and faxes become searchable text.
- **Monitor reports.** Pull the text of filings, papers and policy documents for analysis.

### Input

| Field | Default | Notes |
|---|---|---|
| `pdfUrls` | 3 samples | Up to 100 MB each and 200 per run. Each link must open without signing in. |
| `maxPagesPerPdf` | `50` | Reads at most this many pages of each PDF, starting from page 1. Up to 2,000. |
| `ocrScannedPages` | `true` | Reads pages that have no text layer with OCR. Turn it off for faster runs on digital-only PDFs. |
| `languages` | `eng` | 20 OCR languages. A text layer is read in any language. |
| `maxTextBytesPerRow` | `3000` | Splits long pages across rows. `0` returns one row per page. |

### Every page gets a row that says what happened

| status | method | Meaning | Charged |
|---|---|---|---|
| `ok` | `text-layer` | Text read straight from the PDF | Yes, once per page |
| `ok` | `ocr` | A scanned page read by OCR; see `ocrConfidence` | Yes, once per page |
| `empty` | `none` / `ocr` | The page is blank, or OCR was turned off for a scan | No |
| `download-failed` / `not-a-pdf` / `unreadable` | — | One row per file, with the reason. Covers dead links, web pages, broken or password-protected files | No |

One bad file never fails the run.

### How it works

Pages are read with pdf.js, the PDF engine inside Firefox. When a page has no text, it is rendered and read with Tesseract OCR. Both engines run inside the Actor, so there is no API key and no third-party service. JBIG2, CCITT and JPEG 2000 scans are all decoded.

A text layer is reproduced exactly as the PDF stores it. Charts and diagrams sometimes contain stray glyphs, and those come through too. OCR quality depends on the scan, and `ocrConfidence` tells you which pages to trust.

### Pricing

You pay per page returned with text, whether it was read from the text layer or by OCR. Blank pages, pages beyond your limit and files that fail cost nothing.

### Works well with

Same publisher, same output conventions, same honest-failure rules:

- [**image-to-text-ocr**](https://apify.com/appdata-labs/image-to-text-ocr) — The text in any list of images: screenshots, scans, receipts. 20 languages.

### Disclaimer

This Actor reads only the files you link to: it scrapes no website and calls no third-party API — the OCR engine runs inside the Actor. Make sure you have the right to process the files you submit.

# Actor input Schema

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

Links to the PDFs to read, up to 100 MB each and 200 per run. The link must open without signing in; password-protected PDFs cannot be read. A bad entry is skipped with a reason; the rest still run.

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

Read at most this many pages from each PDF, from page 1. Up to 2,000. Pages beyond the limit are not read or charged.

## `ocrScannedPages` (type: `boolean`):

On by default: a page with no text layer (a scan or a photo) is rendered and read by OCR, and its row says method "ocr". Off: such pages come back empty and uncharged — faster when you know the PDFs are digital.

## `languages` (type: `array`):

The language(s) of the text, as Tesseract codes. English is built in and fastest; other languages load on first use. Pick more than one only for mixed-language documents — each extra language slows reading.

## `maxTextBytesPerRow` (type: `integer`):

Long text is split across several rows of at most this many bytes, at paragraph and line breaks, so each row fits an AI agent's context and drops straight into a RAG pipeline. The page is still charged once. 0 keeps each page whole in one row.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://example.com/annual-report.pdf",
    "https://example.com/scanned-contract.pdf"
  ],
  "maxPagesPerPdf": 500,
  "ocrScannedPages": true,
  "languages": [
    "eng",
    "deu"
  ],
  "maxTextBytesPerRow": 3000
}
```

# Actor output Schema

## `rows` (type: `string`):

Extract text from any list of PDF URLs, one row per page, with title, author and page count

## `summary` (type: `string`):

What was requested, what was read, what was skipped and why.

# 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://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
        "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/linn.pdf",
        "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/skew.pdf"
    ],
    "maxPagesPerPdf": 50,
    "ocrScannedPages": true,
    "languages": [
        "eng"
    ],
    "maxTextBytesPerRow": 3000
};

// Run the Actor and wait for it to finish
const run = await client.actor("appdata-labs/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://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
        "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/linn.pdf",
        "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/skew.pdf",
    ],
    "maxPagesPerPdf": 50,
    "ocrScannedPages": True,
    "languages": ["eng"],
    "maxTextBytesPerRow": 3000,
}

# Run the Actor and wait for it to finish
run = client.actor("appdata-labs/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://raw.githubusercontent.com/mozilla/pdf.js/master/web/compressed.tracemonkey-pldi-09.pdf",
    "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/linn.pdf",
    "https://raw.githubusercontent.com/ocrmypdf/OCRmyPDF/main/tests/resources/skew.pdf"
  ],
  "maxPagesPerPdf": 50,
  "ocrScannedPages": true,
  "languages": [
    "eng"
  ],
  "maxTextBytesPerRow": 3000
}' |
apify call appdata-labs/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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