# Extract Text from PDF: OCR, PDF to Text & Markdown (`data-done-right/pdf-to-text-ocr`) Actor

Convert PDF, Word, PowerPoint, Excel and image files to clean text or Markdown: PDF to text, PDF to Markdown, and OCR PDF for scanned PDF pages, automatically. Extract text from PDF URLs, plus tables as CSV-ready rows. Built for AI and RAG pipelines and data entry.

- **URL**: https://apify.com/data-done-right/pdf-to-text-ocr.md
- **Developed by:** [Data Done Right](https://apify.com/data-done-right) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.32 / 1,000 page converteds

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

This **PDF to text converter** also handles Word, PowerPoint, Excel and images. It turns **any document into clean text or Markdown**, ready for AI, search or data entry. Give file URLs and get the text, the **tables as rows**, and **OCR for scanned pages**, all in one Actor.

### What file types can it convert to text

| Input | What you get |
|---|---|
| **PDF** | Text with correct word spacing (PDFium engine), tables, metadata. **Scanned pages are OCR'd automatically.** |
| **Word (.docx)** | Headings as `#` Markdown, lists, tables |
| **PowerPoint (.pptx)** | Text per slide, slide tables, speaker notes |
| **Excel (.xlsx)** | Every sheet as rows |
| **Images** (PNG, JPG, TIFF, WebP) | OCR text (English, Spanish, French, German, Portuguese, Italian) |
| **HTML / TXT** | Main content as Markdown |

### Why use this PDF to text converter

- **Auto OCR, only where needed.** Pages with a text layer are read directly; only image-only pages go through OCR. That's faster, and you're billed for OCR only on those pages.
- **Tables you can use:** each table is rows × cells, CSV-ready, plus a Markdown version inside the document text.
- **RAG-friendly:** choose *one row per page* for chunking and page citations.
- **Robust batches:** a broken link or corrupt file is listed in `FAILED` and never stops the run.

### How to convert a PDF to text

Put the file links in `urls` and run. The defaults are Markdown output, table extraction on and OCR set to `auto`.

```json
{
  "urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"],
  "outputFormat": "markdown",
  "onePerPage": false,
  "extractTables": true,
  "ocr": "auto",
  "ocrLanguages": ["eng"]
}
```

`outputFormat` can be `markdown`, `text` or `both`. Use `pages` (for example `1-5,8`) to read only some PDF pages and `maxPagesPerDocument` to cap long files and cost.

### Extract text from PDF files in bulk, by API

Call this Actor from the Apify API, Python, JavaScript, Make, Zapier, n8n or Power Automate to extract text from PDF files, scanned PDFs and images, and get JSON back. You can also export to CSV, Excel or Google Sheets. There's no software to install and no per-file upload.

### Use it in Claude, ChatGPT and Cursor

Connect Apify's MCP server (mcp.apify.com) and your AI assistant can read documents itself. For example: "extract the text and tables from this PDF link and summarize it." The only required input is `urls`.

### What data can you extract (output example)

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "fileType": "pdf", "pageCount": 6, "pagesProcessed": 6,
  "ocrPages": [], "wordCount": 6272,
  "markdown": "<!-- page 1 -->\n\nForm W-9 (Rev. March 2024) Request for Taxpayer Identification Number ...",
  "tables": [{"page": 1, "rows": [["Part I", "Taxpayer Identification Number (TIN)"], ["..."]]}]
}
```

### How much does it cost

Pay per event: **$0.0004 per page** converted (1,000 pages ≈ $0.40), plus **$0.005 per page** only for pages that needed OCR. Apify Silver plans get 10% off, Gold and higher 20%.

### FAQ

#### How do I convert a scanned PDF to text?

Leave `ocr` on `auto`. Pages that have a text layer are read directly, and only image-only pages go through OCR. Set `ocr` to `always` to force OCR on every page.

#### How do I extract text from a PDF?

Put the PDF link in `urls` and run. You get the whole document as clean text or Markdown in one field, or one row per page with `onePerPage`.

#### How do I extract text from a PDF to Excel?

Keep `extractTables` on. Each table comes back in the `tables` field as rows of cells, ready to save as CSV and open in Excel or Google Sheets.

#### How do I OCR a PDF?

Give the PDF link in `urls`. Choose the language codes in `ocrLanguages` (English, Spanish, French, German, Portuguese or Italian). The OCR text is returned in the same `markdown` field as the rest of the document, and `ocrPages` lists which pages needed OCR.

#### Can I convert PDF to Markdown for AI and RAG?

Yes. Markdown is the default output. Turn on `onePerPage` to get one row per page, which makes chunking and page citations easy.

#### Can it extract tables from a PDF?

Yes. Each table comes back as rows of cells you can load as CSV, plus a Markdown version inside the document text. Table quality depends on the layout of the source file.

#### Which file types does it support?

PDF, Word (.docx), PowerPoint (.pptx), Excel (.xlsx), images (PNG, JPG, TIFF, WebP), HTML and TXT. Old binary formats such as .doc are not in this list.

#### What happens if one file fails?

A broken link or corrupt file is listed in the `FAILED` record, and the rest of the batch is still converted.

### Related tools

- **File Converter API: PDF, Office, Images, Audio & Video** converts, merges, splits and compresses files instead of reading their text.
- **Extract ZIP Files: Unzip Archives & Email Attachments** pulls the documents out of archives and emails first.
- **AI Web Scraper: Any Page to JSON (Bring Your Own Key)** turns the text of web pages into structured fields.

# Actor input Schema

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

Links to PDF, DOCX, PPTX, XLSX, PNG/JPG/TIFF images, HTML or TXT files.

## `outputFormat` (type: `string`):

Markdown keeps headings and tables; text is plain.

## `onePerPage` (type: `boolean`):

Output each page/slide/sheet separately (handy for RAG chunking and citations).

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

Tables as rows of cells (CSV-ready) plus Markdown tables.

## `ocr` (type: `string`):

Auto = only pages without a text layer get OCR.

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

Tesseract language codes: eng, spa, fra, deu, por, ita.

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

Optional page selection like 1-5,8 (PDF only).

## `maxPagesPerDocument` (type: `integer`):

Caps very long files (and cost).

## `maxConcurrency` (type: `integer`):

Documents processed at the same time.

## `proxyConfiguration` (type: `object`):

Only needed if the file host blocks datacenter IPs.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "outputFormat": "markdown",
  "onePerPage": false,
  "extractTables": true,
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPagesPerDocument": 3,
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

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

All result items of this run (the default dataset), as JSON, CSV, Excel and more.

## `records` (type: `string`):

Key-value store records: the run summary, notes on any problems, and any files.

# 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://www.irs.gov/pub/irs-pdf/fw9.pdf"
    ],
    "maxPagesPerDocument": 3
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-done-right/pdf-to-text-ocr").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://www.irs.gov/pub/irs-pdf/fw9.pdf"],
    "maxPagesPerDocument": 3,
}

# Run the Actor and wait for it to finish
run = client.actor("data-done-right/pdf-to-text-ocr").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://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "maxPagesPerDocument": 3
}' |
apify call data-done-right/pdf-to-text-ocr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-done-right/pdf-to-text-ocr"
        }
    }
}
```

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/nsU2UpyFgOPoSfrPS/builds/1fslM6DyQLZ2jPIPi/openapi.json
