# PDF Text Extractor: PDF to Markdown with OCR (`plain_rows/pdf-text-extractor`) Actor

Extract text from PDFs and convert PDF to Markdown for AI, search and analysis. Give it links to PDF files and get the full text, Markdown with headings, text page by page, metadata and links. Optional OCR reads scanned PDFs. You only pay for PDFs that are read; failed links are free.

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

## Pricing

from $4.00 / 1,000 pdf reads

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: PDF to Text and Markdown, with OCR

Give this Actor links to PDF files and get back clean text you can search, analyse or feed to an AI model: the full text, a Markdown version with headings, text page by page, the document's metadata and the links inside it.

It reads the text layer of the PDF directly, so it is fast and exact: a 15-page research paper takes about a second. Scanned PDFs, which are pictures of pages with no text to copy, can be read with OCR when you turn it on. You are charged only for PDFs that are actually read. Broken links, files that are not PDFs and oversized files are reported and cost nothing.

### What you get for each PDF

- **Full text**, with paragraphs rebuilt from the page layout and words that were hyphenated across lines joined back together.
- **Markdown**, in which lines set in larger type become headings. This is the format most AI tools work best with.
- **Text page by page** (optional), so you can quote a page number or split a document into chunks.
- **Metadata**: title, author, subject, keywords, creation and modification dates, the program that produced the file, page count, word count, and whether it has fillable form fields.
- **Links** found in the document (optional).
- **Scanned pages read with OCR** (optional). Only pages that have no text are sent to OCR, so a document that is mostly ordinary text with a few scanned pages costs only what it needs. Each result says how many pages were read this way and how confident the OCR was.
- **A scan warning.** With OCR off, a scanned PDF is flagged instead of coming back empty without explanation.

### What it is good for

- **Feeding documents to AI.** Turn reports, papers, manuals and contracts into Markdown for retrieval, summaries or question answering.
- **Search and indexing.** Make a folder of PDFs searchable.
- **Research.** Pull the text of papers and filings in bulk.
- **Checks and audits.** Read metadata and word counts across many files, or find which of your PDFs are scans.

### Input

| Field | What it does |
|---|---|
| **PDF links** | One link per PDF. Each must point straight at a PDF file. |
| **Include Markdown** | On by default. |
| **Include text page by page** | Adds a `pages` list with each page's text. |
| **Include links found in the PDF** | Adds a `links` list. |
| **Maximum pages to read per PDF** | Reads only the first pages of long documents. |
| **Read scanned pages with OCR** | Off by default. Reads pages that have no text layer. |
| **Languages in the scanned pages** | Tesseract codes such as `eng`, `spa`, `fra`, `deu`. English if left empty. |
| **Maximum scanned pages to read per PDF** | Default 50. A cap on OCR per document. |
| **Largest file to accept (MB)** | Default 50. Larger files are skipped and not charged. |
| **Password for protected PDFs** | For password-protected files. |

```json
{
    "pdfUrls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://arxiv.org/pdf/1706.03762"
    ],
    "includeMarkdown": true,
    "includePages": true
}
```

### Output

```json
{
    "url": "https://arxiv.org/pdf/1706.03762",
    "fileName": "1706.03762v7.pdf",
    "status": "ok",
    "error": null,
    "pageCount": 15,
    "pagesRead": 15,
    "title": null,
    "author": null,
    "createdAt": "2024-04-10T21:11:43.000Z",
    "hasForm": false,
    "wordCount": 6014,
    "looksScanned": false,
    "text": "Attention Is All You Need ...",
    "markdown": "## Attention Is All You Need\n\nAshish Vaswani ...\n\n### Abstract\n\nThe dominant sequence transduction models ...",
    "pages": [
        {
            "page": 1,
            "text": "...",
            "charCount": 2859
        }
    ],
    "extractedAt": "2026-11-20T22:30:00.000Z"
}
```

A PDF that could not be read comes back with `"status": "failed"` and a plain-language `error`, for example "The link did not return a PDF (it returned text/html)". Metadata fields the document does not contain are `null`.

### Limits

- **OCR is slower and less exact than reading a text layer.** Expect about 5 seconds per scanned page and occasional misread characters, more on poor scans, handwriting and small print. The `ocrConfidence` field (0 to 100) tells you how sure it was.
- **OCR'd pages have no headings.** They come back as plain paragraphs.
- **Tables and multi-column pages** come out as text in reading order, with wide gaps kept as spaces. Table structure is not rebuilt.
- **Headings are detected by type size.** Documents that use bold text of the same size for headings will not get Markdown headings.
- **Links must be reachable without a login.** Files behind a sign-in page cannot be fetched.
- Files over the size limit you set (200 MB at most) are skipped.

### Pricing

You pay per PDF that is read, plus a per-page charge only for pages read with OCR. Links that fail, files that are not PDFs and files over your size limit are free.

### How to extract text from a PDF

1. Paste one or more links to PDF files into **PDF links**. Each link has to point straight at the file.
2. Leave **Include Markdown** on if the text is going to an AI model. Turn on **Include text page by page** if you need page numbers.
3. If your PDFs are scans, turn on **Read scanned pages with OCR**.
4. Click **Start**. Ordinary PDFs take a second or two each; scanned pages take about 5 seconds each.
5. Download the results as JSON, or read them through the API from your own code.

### How much does it cost to extract text from PDFs?

You pay **$0.005 per PDF that is read**, whatever its length, so 1,000 PDFs cost $5. Pages read with OCR cost **$0.01 each** on top, and only pages that have no text are sent to OCR.

Links that fail, files that are not PDFs and files over your size limit are free. Apify's free plan includes $5 of usage a month, which is about 1,000 ordinary PDFs. Users on Apify's Silver plan pay 10% less and on Gold 20% less.

### Frequently asked questions

#### Can it convert a PDF to Markdown for an AI model or RAG pipeline?

Yes. Markdown is on by default: lines set in larger type become headings and paragraphs are rebuilt, which is the shape most AI tools handle best.

#### Does it work on scanned PDFs?

Yes, with OCR turned on. With OCR off, a scanned PDF is flagged with `looksScanned` so you know why there is no text.

#### Which languages does OCR support?

English by default. Add Tesseract language codes such as `spa`, `fra` or `deu` for others.

#### Does it extract tables?

Table text is extracted in reading order, but the rows and columns are not rebuilt into a table.

#### Can it read password-protected PDFs?

Yes, if you supply the password in the input.

#### Can I upload a file instead of giving a link?

The Actor reads links. Upload the file somewhere it can be fetched without a login, such as an Apify key-value store, and use that link.

### Other tools by Plain Rows

- [ATS Jobs Scraper](https://apify.com/plain_rows/ats-jobs-scraper): Search 11,400+ company career pages by keyword, with pay ranges and an only-new mode.
- [Greenhouse Jobs Scraper](https://apify.com/plain_rows/greenhouse-jobs-scraper): Greenhouse boards in depth: pay ranges, departments, offices and custom fields.
- [US New Business Leads](https://apify.com/plain_rows/us-business-registry): Newly registered and newly licensed businesses from official state and city data.
- [Image to Text OCR](https://apify.com/plain_rows/image-ocr-text): Text from screenshots, scans and photos of documents, in 100+ languages.
- [Bulk Domain Lookup](https://apify.com/plain_rows/domain-lookup): Registration dates, availability, DNS records, mail provider, SPF and DMARC for a list of domains.
- [Website Screenshot](https://apify.com/plain_rows/website-screenshot): Full-page or mobile screenshots of many web pages at once.

### Questions or problems

Open the **Issues** tab on this Actor's page and describe what you ran and what you expected. Issues are answered there.

# Actor input Schema

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

One link per PDF. Each link must point straight at a PDF file.

## `includeMarkdown` (type: `boolean`):

Add a Markdown version in which larger-type lines become headings. Good for feeding documents to AI models.

## `includePages` (type: `boolean`):

Add a list with the text of each page separately, so you can cite or split by page.

## `includeLinks` (type: `boolean`):

Add the web links that appear in the document.

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

Read only the first pages of long documents. Leave empty to read every page.

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

When on, pages that have no text are read with OCR. Pages that already have text are never sent to OCR, so mixed documents cost only what they need.

## `ocrLanguages` (type: `array`):

Three-letter Tesseract language codes, for example eng, spa, fra, deu, ita, por. Leave empty for English.

## `maxOcrPagesPerPdf` (type: `integer`):

A safety cap so one very long scan cannot run up a large charge.

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

Files larger than this are skipped and reported, not charged.

## `password` (type: `string`):

Only needed if your PDFs are password-protected. The same password is tried on every file.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "includeMarkdown": true,
  "includePages": false,
  "includeLinks": false,
  "ocrScannedPages": false,
  "maxOcrPagesPerPdf": 50,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

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

One item per PDF.

## `runSummary` (type: `string`):

How many PDFs were read, failed, or look like scans.

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

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

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

```

## MCP server setup

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