# PDF Text Extractor — PDF to Text & Markdown, with OCR (`steadyscrape/pdf-text-extractor`) Actor

PDF to text API: extract the full text of PDFs as plain text and Markdown, one row per PDF with title, author, page count and dates. A parser that reads each page's own text and OCRs scanned pages. Drive, Dropbox and dataset links. Export to JSON, CSV or Excel, or via API.

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

## Pricing

from $0.50 / 1,000 page read from the pdf's own texts

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 Text Extractor — PDF to text and Markdown, with OCR for scanned pages

A **PDF text extractor and PDF to text API**: give it links to PDFs and get **one row per PDF** with its **whole
text**, a **Markdown** version, and its **document information** — title, author, subject, keywords, the programs
that made it, creation and modification dates, PDF version, page count — plus the language most of its text is in.
Each PDF can also be saved as a `.txt` and a `.md` file behind a link that opens for anyone, and you can ask for one
extra row per page.

**Every page is read from the PDF's own text first.** A page made by a program (Word, LaTeX, a browser, an invoicing
system) carries its text: it is read exactly, in milliseconds, for **US$0.50 per 1,000 pages**. **Only scanned pages
are OCR'd**, by an open OCR model running inside the Actor (no cloud OCR API, no LLM, nothing your PDFs are sent to).
Mixed PDFs — typed pages with scanned attachments — come out whole in one run.

### PDF text extraction pricing

| event | price | when |
|---|---|---|
| `text-page` | **US$0.0005** (US$0.50 per 1,000 pages) | a PDF page read from its own text |
| `page` | **US$0.0025** (US$2.50 per 1,000 pages) | a scanned page read by OCR |

The document row itself costs nothing: you pay for the pages read. A link that does not answer, a web page, a
password-protected PDF, a page without text: each is free, and the row says why.

### What the PDF extractor reads

- **PDFs**: every page, or the pages you ask for (`1-3, 5, 10-`), up to 100 per PDF by default (2,000 at most).
- **Scanned PDFs and scans**: pages without their own text are OCR'd (Latin-alphabet languages and Chinese by
  default; Japanese, Korean, Cyrillic, Arabic, Devanagari, Thai, Greek, Tamil and Telugu on request). TIFF scans and
  images work too.
- **Share links**: Google Drive files, Google Docs (exported to PDF) and Dropbox links shared with "Anyone with the link".
- **Another Actor's output**: pick a dataset (scraped PDFs, filings, reports, invoices) and name the field that holds
  the links, or let the Actor find the PDF fields itself. Signed links of Apify key-value records work as they are.

Pages of YouTube, TikTok, Instagram and other platforms are refused before anything is downloaded: this Actor reads
your own files.

### Use cases

- **LLM and RAG pipelines**: whole documents as clean text and Markdown with page headings, in one JSON row each,
  ready to chunk and embed; the title, author and dates for the index.
- **Document archives to searchable text**: contracts, reports, papers, manuals and scanned letters, typed and
  scanned pages alike, with a `.txt` per PDF whose pages are apart by a form feed, as pdftotext writes them.
- **Scraped PDFs**: run it on the dataset of a scraper that collected PDF links (tenders, filings, court documents,
  datasheets) and keep the dataset item each PDF came from.
- **Metadata audits**: who wrote a PDF, with what program, and when, across a whole folder of links.

### Input

| field | what it does |
|---|---|
| `files` | PDF links, up to 300 MB each and 1,000 per run. |
| `datasetId` / `datasetFields` | A dataset of another run and the fields holding its PDF links (`attachments.url` takes the url of every element of `attachments`). Empty fields: the Actor picks pdf, document, file, report, invoice and scan fields. |
| `pdfMode` | `auto` (default: each page's own text, OCR for scanned pages), `ocr` (OCR every page, for PDFs whose own text is wrong), `text-layer-only` (never OCR). |
| `pages` | Which pages of each PDF, like `1-3, 5, 10-`. Empty: every page. |
| `maxPagesPerFile` | Pages past this are left out, free, and named in the document's note (default 100). |
| `script` | The alphabet of scanned pages: `latin` (default), `japanese`, `korean`, `cyrillic`, `arabic`, `devanagari`, `thai`, `greek`, `tamil`, `telugu`. A PDF's own text is read in any language. |
| `autoRotate` | OCR scanned pages turned 90, 180 or 270 degrees the right way up (default on). |
| `outputFiles` | Files saved per PDF: `txt` and `md` by default, `json` (pages → blocks → lines with boxes) on request. |
| `pageRows` | Also one row per page (`rowType: "page"`) with its text, blocks and lines with boxes. Off by default. |

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

### Output: one row per PDF

This is the real row of the example above, its text and Markdown shortened:

```json
{
    "rowType": "document",
    "status": "ok",
    "reason": null,
    "fileIndex": 1,
    "sourceUrl": "https://arxiv.org/pdf/1706.03762",
    "datasetItemIndex": null,
    "fileName": "1706.03762v7.pdf",
    "fileType": "pdf",
    "fileSizeBytes": 2215244,
    "pageCount": 15,
    "pagesRead": 15,
    "textLayerPages": 15,
    "ocrPages": 0,
    "pagesWithoutText": 0,
    "title": null,
    "author": null,
    "subject": null,
    "keywords": null,
    "creator": "LaTeX with hyperref",
    "producer": "pdfTeX-1.40.25",
    "creationDate": "2024-04-10T21:11:43Z",
    "modificationDate": "2024-04-10T21:11:43Z",
    "pdfVersion": "1.5",
    "language": "en",
    "script": "Latin",
    "text": "Provided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in journalistic or\nscholarly works.\n\nAttention Is All You Need\n\nAshish Vaswani∗\nGoogle Brain\navaswani@google.com\n…",
    "markdown": "# 1706.03762v7.pdf\n\n## Page 1\n\nProvided proper attribution is provided, …",
    "textTruncated": false,
    "wordCount": 6277,
    "charCount": 33470,
    "textFileUrl": "https://api.apify.com/v2/key-value-stores/…/records/001-1706-03762v7.txt?signature=…",
    "markdownFileUrl": "https://api.apify.com/v2/key-value-stores/…/records/001-1706-03762v7.md?signature=…",
    "jsonFileUrl": null,
    "unreadFields": [],
    "processingSeconds": 2.42,
    "processedAt": "2026-11-19T03:06:38.849Z"
}
```

This paper's PDF carries no title or author in its document information (LaTeX leaves them empty unless the author
sets them), so they are `null`: the Actor gives what the PDF says, never a guess from the text.

#### Fields

| field | meaning |
|---|---|
| `rowType` | `document` (one per PDF), or `page` with `pageRows` on. |
| `status` | `ok` when at least one page was read; otherwise why nothing was: `no_text`, `invalid`, `unreachable`, `not_supported`, `too_large`, `protected`, `refused`, `skipped`, `failed`. |
| `reason` | What was left out and why, page by page ("page 4: no text was found on this page"); `null` when every page asked for was read. |
| `pageCount`, `pagesRead` | Pages in the PDF, and pages read with text in this run. |
| `textLayerPages`, `ocrPages` | How the pages read were read, and billed: from the PDF's own text (`text-page`) or by OCR (`page`). |
| `pagesWithoutText` | Pages with nothing to read (blank, or scanned in `text-layer-only` mode). |
| `title`, `author`, `subject`, `keywords`, `creator`, `producer` | The PDF's document information as its program wrote it; `null` when the PDF has none. |
| `creationDate`, `modificationDate` | ISO 8601, in UTC when the PDF gives its time zone, as written (no offset) when it does not. |
| `pdfVersion` | `1.4`, `1.7`, `2.0`… |
| `language`, `script` | The language most of the text is in (`en`, `de`, `zh`…; `null` when too short to tell) and its Unicode script. |
| `text` | Every page read, in page order: lines on their own lines, paragraphs apart by a blank line, pages apart by a form feed line. |
| `markdown` | The PDF as Markdown: the file as a title, a heading per page, paragraphs; big single lines of scanned pages become subheadings. |
| `textTruncated` | `true` when the text or the Markdown passed 1,000,000 characters: the row has the beginning, and the `.txt` and `.md` files (then always saved) have all of it. |
| `wordCount`, `charCount` | Counts of the whole text (Chinese and Japanese words included). |
| `textFileUrl`, `markdownFileUrl`, `jsonFileUrl` | The PDF's files: links that open for anyone. |
| `unreadFields` | Information fields that could not be read on this PDF (a broken date, an unreadable dictionary), as opposed to absent. |
| `fileIndex`, `fileName`, `fileType`, `fileSizeBytes`, `sourceUrl`, `datasetItemIndex` | The link's place in the input, the file as its server names it, its type and size, the link as given, and the dataset item it came from. |
| `processingSeconds`, `processedAt` | How long the PDF took to read, and when (UTC, ISO 8601). |

With `pageRows` on, each page also gets a row with `rowType: "page"`, `pageNumber`, `method` (`text-layer` or `ocr`),
its `text`, `blocks` and `lines` (each with a box, and a confidence for OCR), `language`, `confidence` and
`billedEvent`. They come before their document's row.

### Speed and memory

A page with its own text is read in milliseconds: on Apify, at the default 1 GB, the 15 pages of the example took
2.4 s and the whole run 9 s, peaking at 146 MB. A dense scanned A4 page took 2.1–2.3 s of OCR at 2 GB in this engine's
measurements, and takes longer at 1 GB, since Apify gives a run one CPU core per 4 GB. The default memory fits A4 and
Letter scans; give a run more for large posters or plans, or to OCR faster.

If your spending limit pays only for part of a run, the Actor stops at the limit and says which pages it did not read;
when only `text-page` is left, it still reads pages that have their own text. A run moved by Apify to another server
goes on where it was: no page is read or billed twice, and each PDF still gets one complete row.

### Limits

- Headings inside a page come from the size of its lines on scanned pages only; on pages with their own text the
  Markdown has the page headings and paragraphs.
- Tables come out as rows of text, not as cells; handwriting is not read reliably.
- Password-protected PDFs are not opened (remove the password); Word and Excel files must be exported to PDF first.
- A PDF whose own text is garbled (broken fonts) is usually caught and OCR'd; if one slips through, use `pdfMode: ocr`.
- The title and author come from the PDF's document information dictionary; a PDF that keeps them only in XMP metadata
  shows them as `null`.

### Is it legal?

It reads files you give it: your own documents, or files you have the right to process. Do not use it on documents
that contain other people's personal data unless you have a lawful basis to process them (GDPR, CCPA and similar).

This Actor is not affiliated with, endorsed by or connected to Adobe, arXiv, Google, Dropbox, PaddlePaddle or RapidAI.
It reads PDFs with pdfium (BSD-3) through pypdfium2 and OCRs with the open PP-OCR models (Apache-2.0) through RapidOCR
(Apache-2.0).

### Related

- [OCR: Image & PDF to Text](https://apify.com/steadyscrape/ocr-image-pdf-to-text): the same engine with one row per
  page or image, each line with its box and confidence, for screenshots, photos and receipts.
- Questions or a PDF it reads badly? Open an issue on the Actor's Issues tab; it is answered.

# Actor input Schema

## `files` (type: `array`):

Links to your own PDFs, up to 300 MB each: direct links, Google Drive and Dropbox share links (shared with anyone with the link), Google Docs links (exported to PDF) and signed links of Apify key-value records work as they are. Scanned PDFs, TIFF scans and images are read by OCR. Pages of Instagram, TikTok, YouTube and other platforms are refused before anything is downloaded, free.

## `datasetId` (type: `string`):

Pick the dataset of another run (scraped PDFs, reports, invoices, filings) and every PDF link in it is read. Only the dataset you pick here can be read.

## `datasetFields` (type: `array`):

The fields of each dataset item that hold the PDF links, as dotted paths (attachments.url takes the url of every element of attachments). Leave empty to take every link in a field named like pdf, document, file, report, invoice or scan, or ending in .pdf.

## `pdfMode` (type: `string`):

A PDF page made by a program (Word, LaTeX, a browser, an invoicing system) carries its own text: <b>auto</b> reads that text exactly and cheaply (the <code>text-page</code> event) and OCRs only scanned pages (the <code>page</code> event). <b>Always OCR</b> reads every page from its picture, for PDFs whose own text is wrong. <b>Own text only</b> never OCRs: scanned pages are left out, free, and named in the document's note.

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

Which pages of each PDF or multi-page TIFF to read, like <code>1-3, 5, 10-</code> (10- is page 10 to the end). Empty reads every page, up to the limit below.

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

Pages past this are left out, free, and named in the document's note, so one long PDF cannot spend the whole run.

## `script` (type: `string`):

For scanned pages only (a PDF's own text is read as it is, in any language). One run OCRs one script: the default reads English, Spanish, French, German, Portuguese, Italian, Dutch, the Nordic languages, Indonesian and other Latin-alphabet languages, plus Chinese. Polish, Czech, Romanian and Vietnamese scans lose some accents.

## `autoRotate` (type: `boolean`):

Find scanned pages whose text is turned 90, 180 or 270 degrees and OCR them the right way up.

## `outputFiles` (type: `array`):

One file per PDF in the run's key-value store, every page in order, linked from its document row by a link that opens for anyone: <b>txt</b> (pages apart by a form feed, as pdftotext writes them), <b>md</b> (Markdown with page headings), <b>json</b> (pages, blocks and lines with their boxes). The document row carries the text and the Markdown either way; a PDF longer than a row holds (1,000,000 characters) gets its .txt and .md saved whatever is chosen here.

## `pageRows` (type: `boolean`):

Besides the one row per PDF, a row per page with its text, blocks and lines with boxes, language and how it was read (<code>rowType: "page"</code>). Pages are charged the same either way.

## Actor input object example

```json
{
  "files": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "pdfMode": "auto",
  "maxPagesPerFile": 100,
  "script": "latin",
  "autoRotate": true,
  "outputFiles": [
    "txt",
    "md"
  ],
  "pageRows": false
}
```

# Actor output Schema

## `documents` (type: `string`):

No description

## `files` (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 = {
    "files": [
        "https://arxiv.org/pdf/1706.03762"
    ]
};

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

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

```

## MCP server setup

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