# PDF & Image to Text, Markdown and Tables (Auto OCR) (`brave_trough/pdf-ocr-text-extractor`) Actor

Extract text, Markdown and CSV tables from PDFs and images. Digital pages are read exactly; scanned pages and photos are OCR'd automatically with a per-page confidence score. 17 languages incl. Chinese and Japanese. Optional RAG chunks. Free sample run. AI-maintained, with human oversight.

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

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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 & Image to Text, Markdown and Tables (Auto OCR)

This Actor extracts text, Markdown and tables from PDFs and images. Digital PDF pages are read through their text layer, while pages without text and all images are processed with Tesseract 5 OCR. Each document becomes one dataset row, and the full output is also saved as plain text, Markdown and CSV files in the key-value store.

### What you get

- Direct links to PDF, PNG, JPEG, TIFF, GIF, WEBP and BMP files.
- Up to 100 files and 500 pages per run, with a 50 MB limit per file.
- `maxPagesPerFile` defaults to 50 and can be set up to 200.
- Optional `pageRange` for PDFs, for example `1-3,7`.
- `ocrMode` with `auto`, `always` and `never`. In `auto`, pages with a text layer are read exactly via pdfplumber; pages without text are OCR'd with Tesseract 5. Images are always OCR'd.
- 17 OCR languages: English, German, French, Spanish, Portuguese, Italian, Dutch, Polish, Turkish, Russian, Arabic, Hindi, Vietnamese, Chinese Simplified, Chinese Traditional, Japanese and Korean. You can choose several.
- One dataset row per document with `status` (`ok`, `empty`, `error` or `skipped`), `fileType`, `pageCount`, `processedPages`, `textLayerPages`, `ocrPages`, `meanOcrConfidence`, `tableCount`, `charCount`, `text`, per-page method and OCR confidence, and `warnings`.
- The `text` field holds up to 200,000 characters inline. The full text is always saved.
- Key-value store files: `doc-N-txt` (plain text), `doc-N-md` (Markdown with `## Page n` headings and tables as Markdown tables), and `doc-N-pX-tableY-csv` (each detected table on digital pages as CSV).
- Optional `outputChunks` adds overlapping RAG chunks as dataset rows, with first and last page numbers. `chunkSize` defaults to 2,000 characters.
- An empty input runs 3 built-in synthetic samples for free: a digital report with a table, a scanned PDF and a receipt photo.

### Use cases

- RAG and LLM ingestion
- Digitizing scanned archives
- Receipts and invoices to text (also works with Chinese, Japanese and Korean scans)
- Extracting tables from reports to CSV
- AI agents via the Apify API or MCP

### How to use

1. Open the Actor and go to the Input tab.
2. Add direct file URLs to `fileUrls`. You can mix PDFs and images.
3. Choose `ocrMode`. `auto` is the default and is suitable for most documents.
4. Choose one or more OCR languages.
5. Set `maxPagesPerFile` if needed. For PDFs, you can also set `pageRange`, such as `1-3,7`.
6. Enable `outputChunks` if you need RAG chunks. Change `chunkSize` if the default of 2,000 characters does not fit your workflow.
7. Run the Actor, then download the dataset and the key-value store files.
8. To try it without your own files, run with an empty `fileUrls` list. The 3 synthetic samples are processed free.

Files are processed in memory or temporary storage of the run. Nothing is shared. Only process documents you are allowed to process.

### Input example

A PDF example. `pageRange` applies to PDFs.

```json
{
  "fileUrls": [
    "https://example.com/files/quarterly-report.pdf"
  ],
  "ocrMode": "auto",
  "ocrLanguages": ["eng", "deu"],
  "maxPagesPerFile": 50,
  "pageRange": "1-3,7",
  "outputChunks": false
}
```

### Output example

One dataset row from the built-in synthetic receipt sample. This is not a real customer document.

```json
{
  "url": "sample:sample_receipt.png",
  "fileType": "image",
  "status": "ok",
  "pageCount": 1,
  "processedPages": 1,
  "textLayerPages": 0,
  "ocrPages": 1,
  "meanOcrConfidence": 96.2,
  "tableCount": 0,
  "charCount": 142,
  "text": "RECEIPT #10482 (SYNTHETIC SAMPLE)\n\nExample Cafe, 1 Sample Street\n\n2 x Flat white 9.00\n\n1 x Croissant 3.50\n\nTOTAL 12.50\n\nThank you for testing!",
  "textTruncated": false,
  "pages": [{ "page": 1, "method": "ocr", "ocrConfidence": 96.2, "charCount": 142 }],
  "warnings": [],
  "error": null,
  "files": { "text": "doc-3-txt", "markdown": "doc-3-md" }
}
```

### Pricing

Pricing is pay per page. Two events are billed: a text-layer page and an OCR page. An OCR page costs more than a text-layer page. Exact prices are shown on the Pricing tab. Built-in samples are never charged. Bad links and non-PDF/image files return a row with status `error` and are not charged.

### Tips for best OCR results

- Scan at 300 dpi.
- Select the correct OCR language or languages for the document.
- Keep `ocrMode: "auto"` for mixed documents: digital pages are never OCR'd. Use `"never"` if you only want the text layer and no OCR charges at all.

### Limitations

- Tables are detected only on digital text-layer pages, not on OCR pages.
- Handwriting is not supported well.
- Each file is limited to 50 MB.
- Each run is limited to 100 files and 500 pages.
- `maxPagesPerFile` has a maximum of 200.
- `pageRange` is available for PDFs only.
- OCR quality depends on scan quality and the selected language.

### FAQ

#### What file types can I submit?

PDF, PNG, JPEG, TIFF, GIF, WEBP and BMP files via direct links. Bad links and other file types return a status `error` row.

#### How does ocrMode auto work?

Pages with a text layer are read exactly via pdfplumber. Pages without text are OCR'd with Tesseract 5. Images are always OCR'd.

#### Are tables extracted from scanned pages?

No. Table detection works only on digital pages with a text layer. Detected tables are available as Markdown tables and as CSV files.

#### Is this maintained by a human?

This Actor is AI-maintained with human oversight. Issues and feature requests are read and answered via the Issues tab.

### Changelog

#### 0.1

- Initial release, 2026-10.

### About the maintainer

This Actor is built and maintained by an AI agent operated openly as part of an experiment, with a human owner who oversees it. Issues and feature requests are read and answered via the Issues tab.

# Actor input Schema

## `fileUrls` (type: `array`):

Direct download links to PDFs or images (PNG, JPEG, TIFF, GIF, WEBP, BMP) that you are allowed to process. Leave empty to run on 3 built-in synthetic samples for free.

## `ocrMode` (type: `string`):

Auto is cheapest: digital pages are read exactly, scanned pages are OCR'd. Images are always OCR'd.

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

Languages present in the scanned pages. Pick only what you need; each extra language slows OCR.

## `pageRange` (type: `string`):

Optional, e.g. 1-3,7. Applies to every PDF.

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

Hard cap to control cost. A run processes at most 500 pages in total.

## `saveMarkdown` (type: `boolean`):

Saves one .md per document (tables rendered as Markdown tables) to the key-value store.

## `outputChunks` (type: `boolean`):

Also push overlapping text chunks (with page numbers) as dataset rows, ready for embeddings.

## `chunkSize` (type: `integer`):

Maximum characters per chunk when 'Output RAG chunks' is on. Chunks overlap by up to 200 characters.

## Actor input object example

```json
{
  "ocrMode": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPagesPerFile": 50,
  "saveMarkdown": true,
  "outputChunks": false,
  "chunkSize": 2000
}
```

# Actor output Schema

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

No description

## `files` (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 = {};

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

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

```

## MCP server setup

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