# PDF Text Extractor – Text, Markdown, Tables & OCR (`olliolli/pdf-text-extractor-ocr`) Actor

Extract text, Markdown and tables (CSV) from your PDFs. OCR for scanned PDFs in English, Dutch, French, German, Spanish, Italian, Portuguese. No API key. From $4 per 1,000 PDFs.

- **URL**: https://apify.com/olliolli/pdf-text-extractor-ocr.md
- **Developed by:** [Tom J](https://apify.com/olliolli) (community)
- **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 processeds

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** for your own files: convert **PDF to text, clean Markdown and tables (CSV)** in one run. Scanned pages are read with **OCR** (Tesseract) in English, Dutch, French, German, Spanish, Italian and Portuguese. Built for document pipelines, RAG and LLM workflows. No API key, nothing sent to other services. From **$4 per 1,000 PDFs**.

### What you can do with it

- **Convert PDF to Markdown for RAG and LLMs**: headings, paragraphs and tables as Markdown, pages separated by `---`.
- **Extract tables to CSV**: every ruled table as rows and as a CSV file.
- **OCR scanned PDFs** in 7 languages, automatically only on pages without a text layer.
- **Process PDFs in bulk** from links, Google Drive or Dropbox share links, uploads, base64 or another Actor's dataset.
- **Read metadata**: title, author, creation date, producer, page and word counts.

### How to convert PDF to text in 3 steps

1. **Add PDFs**: PDF links, **Upload PDFs**, `base64Pdfs` (API) or a dataset from another Actor.
2. **Choose what to extract** (text, Markdown, tables, text per page) and the OCR languages.
3. **Click Start.** Each PDF becomes one row, with links to .txt, .md and a zip of CSV tables.

### Where the PDFs can come from

| Source | How |
|---|---|
| Direct link | `urls` |
| Google Drive, Dropbox, OneDrive, SharePoint | Share link in `urls`, set to "Anyone with the link" |
| Your computer | `uploadedFiles` |
| API | `base64Pdfs`: `[{"name": "file.pdf", "data": "<base64>"}]`, max 25 MB each |
| Another Actor | `datasetId` + `urlField` (e.g. `url` or `document.pdfUrl`) |

Web pages are not supported; WeTransfer page links need the direct download link.

### Input

| Field | Meaning | Default |
|---|---|---|
| `outputs` | Text, Markdown, tables, text per page | text, Markdown, tables |
| `ocr` | `auto` (pages with < 40 characters of text), `force`, `off` | `auto` |
| `ocrLanguages` | Languages in the scans (fewer = faster, more accurate) | eng, nld, fra, deu |
| `pdfPassword` | Tried on every file; never logged | — |
| `maxPages` | Pages after this are skipped | 200 (max 1,000) |
| `maxOcrPagesPerPdf` | Upper limit for paid OCR pages per PDF | 50 (max 500) |
| `maxPdfSizeMb` | Larger files are not downloaded or charged | 100 (max 500) |
| `timeoutPerPdfSecs` | Pages read so far are kept | 120 (max 1,800) |

### Output

```json
{
  "fileName": "report.pdf",
  "status": "text_layer",
  "pageCount": 2,
  "textPages": 2,
  "ocrPages": 0,
  "wordCount": 90,
  "preview": "Quarterly overview\nSales by region…",
  "fullText": "…",
  "markdown": "…",
  "tables": [{ "page": 1, "index": 0, "rows": [["Region", "Q3"]], "csv": "Region,Q3\n…" }],
  "tableCount": 2,
  "metadata": { "title": "Quarterly overview (test)", "author": "Test Author", "created": "2026-10-24T15:20:40+00:00" },
  "files": { "txt": "…/001-report.txt", "md": "…/001-report.md", "tables_csv": "…/001-report-tables.zip" },
  "charged": { "pdf": 1, "ocrPages": 0, "tables": 2 }
}
```

The run summary (`OUTPUT`) lists counts per status, pages, OCR pages, tables and what was charged. Export as JSON, CSV, Excel or XML.

| Status | Meaning | Charged |
|---|---|---|
| `text_layer` / `ocr` / `mixed` | Read from text layer, OCR, or both | yes |
| `partial` | Page, OCR or time limit reached (`statusMessage` says why) | for what was read |
| `no_text`, `encrypted`, `too_large`, `download_failed`, `unsupported_source`, `failed` | Nothing usable | no |

### PDF to Markdown for RAG and LLM pipelines

Markdown headings come from font sizes, tables become Markdown tables and two-column pages are read column by column. Chunk the `.md` file straight into your vector database or pass it to an LLM.

### Scanned PDF OCR in 7 languages

English, Dutch, French, German, Spanish, Italian and Portuguese. Clean printed pages read well; faint copies, photos at an angle and handwriting less so.

### How much does PDF extraction cost?

| Event | Price |
|---|---|
| PDF processed | $0.004 |
| OCR page | $0.012 |
| Table extracted | $0.002 |

**Examples:** 1,000 text PDFs without tables = **$4**. 1,000 PDFs with 2 scanned pages each = $4 + $24 = **$28**.

#### What you are not charged for

Files that could not be downloaded, unsupported links, files over the size limit, password-protected files without the right password, damaged files and PDFs without any text. When your maximum cost per run is reached, the Actor stops cleanly and lists the remaining PDFs in `OUTPUT`.

### Integrate with any app

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("olliolli/pdf-text-extractor-ocr").call(
    run_input={"urls": ["https://example.com/report.pdf"], "outputs": ["markdown", "tables"]}
)
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["status"], row["files"]["md"])
```

In **n8n, Make or Zapier**, run the Actor and fetch `files.md` or `files.txt` from each row. To chain after another Actor, pick its dataset in the dataset field. Through Apify's **MCP** server, AI assistants can call it as a PDF reader.

### Privacy

Your files are downloaded into the run, processed there and deleted when the run ends. Text and files are stored only in your own Apify run storage. **Nothing is sent to other services.** Passwords are never logged or stored.

### Good to know

- Tables are detected when they have ruling lines; tables without lines come out as text, and tables on scanned pages as OCR text.
- Up to 1,000 pages, 500 MB and 30 minutes per PDF (you set the limits).
- This Actor does not extract invoice fields.

### FAQ

**Can it OCR scanned PDFs?** Yes, automatically on pages without a text layer, or on every page with `ocr: force`.

**Which OCR languages are supported?** English, Dutch, French, German, Spanish, Italian, Portuguese.

**Can I upload a PDF instead of a link?** Yes, with Upload PDFs, or as base64 through the API.

**Does it extract tables to CSV?** Yes, ruled tables become rows and CSV files (zipped per PDF).

**Is my PDF stored or shared?** No. It is processed inside the run, deleted afterwards and never sent elsewhere.

**What about password-protected PDFs?** Add the password in `pdfPassword`. Without it the row is `encrypted` and free.

### Need help?

Open an issue on the **Issues** tab.

# Actor input Schema

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

Direct links to PDF files. Share links from Google Drive, Dropbox, OneDrive and SharePoint are converted to download links automatically (set sharing to "Anyone with the link"). Web pages are not supported: the link must open the PDF itself.

## `uploadedFiles` (type: `array`):

Upload PDF files from your computer. They are stored in a key-value store of your Apify account and read from there.

## `base64Pdfs` (type: `array`):

For API use: a list of {"name": "file.pdf", "data": "<base64>"} objects. Maximum 25 MB per file. A data: URL is accepted too.

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

Process the PDF links found in a dataset, for example the output of another actor. Pick the dataset here so this actor gets read access to it.

## `urlField` (type: `string`):

Field of each dataset item that holds the PDF link. Use a dot for nested fields (e.g. "document.pdfUrl"). A field with a list of links is fine too.

## `pdfPassword` (type: `string`):

Password for protected PDFs (tried on every file). It is never written to the log or the output.

## `outputs` (type: `array`):

Plain text, Markdown (headings, paragraphs and tables), tables as rows and CSV, and/or the text per page.

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

Auto: read pages without a text layer (fewer than 40 characters) with OCR. Force: OCR every page. Off: text layer only.

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

Languages in your scans. Fewer languages is a little faster and more accurate.

## `maxPages` (type: `integer`):

Pages after this number are skipped (the row gets status "partial").

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

Upper limit for paid OCR pages per PDF. Pages over the limit are left without OCR (status "partial").

## `maxPdfSizeMb` (type: `integer`):

Larger files are not downloaded and not charged.

## `timeoutPerPdfSecs` (type: `integer`):

Reading a PDF stops after this time. Pages already read are delivered (status "partial").

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "urlField": "url",
  "outputs": [
    "text",
    "markdown",
    "tables"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng",
    "nld",
    "fra",
    "deu"
  ],
  "maxPages": 200,
  "maxOcrPagesPerPdf": 50,
  "maxPdfSizeMb": 100,
  "timeoutPerPdfSecs": 120
}
```

# Actor output Schema

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

One row per PDF: status, page counts, full text, Markdown, tables and links to the .txt, .md and CSV files.

## `files` (type: `string`):

The .txt, .md and table CSV/ZIP files of this run.

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

PDFs processed per status, pages, OCR pages, tables, charged events and why a run stopped early (OUTPUT).

# 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"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("olliolli/pdf-text-extractor-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"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,olliolli/pdf-text-extractor-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/UoMJgEQgEH8aQn4Uo/builds/8hUhCSeiKB1f77Her/openapi.json
