# OCR Text Extractor - Images & Scanned PDFs to Text (`scrapesage/ocr-text-extractor`) Actor

Extract text from images (PNG, JPG, TIFF, WEBP, BMP, GIF) and scanned PDFs with Tesseract OCR in 28 languages. Per-page text, confidence scores, optional word boxes, automatic text-layer detection for born-digital PDFs. No API key, no browser. JSON, CSV, Excel.

- **URL**: https://apify.com/scrapesage/ocr-text-extractor.md
- **Developed by:** [Scrape Sage](https://apify.com/scrapesage) (community)
- **Categories:** AI, Automation, Developer tools
- **Stats:** 3 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.65 / 1,000 ocr pages

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## OCR Text Extractor - Images & Scanned PDFs to Text

Turn images and scanned PDFs into clean, structured text. Give the actor a list of links to **PNG, JPG, TIFF, WEBP, BMP or GIF images** or **PDF files** and get back the recognised text, **per-page text**, **confidence scores**, optional **word bounding boxes**, and a status for every file - as JSON, CSV or Excel.

Powered by **Tesseract OCR 5** (LSTM engine) with **28 languages** built in, plus **automatic text-layer detection**: PDFs that already contain selectable text are read exactly and instantly, and only true scans are rasterised and OCR-ed. No API key, no OCR subscription, no browser - it all runs inside the actor.

> **Why this actor exists:** the OCR / image-to-text niche on Apify draws hundreds of monthly users across tools that either call an external OCR API (and pass on its cost) or only read PDFs that already have a text layer. This one does real OCR on scans and photos, reads born-digital PDFs for free, and prices per page at a fraction of a cent.

### What you get per file

| Field | Description |
|---|---|
| `text` | The full recognised text of the file (all pages joined) |
| `pages[]` | Each page separately: `page`, `text`, `wordCount`, `meanConfidence`, `method` (`ocr` or `text-layer`) |
| `words[]` | Optional: every word with `confidence` (0-100) and its box `left`, `top`, `width`, `height` in pixels |
| `meanConfidence` `minPageConfidence` | OCR confidence (0-100) averaged over words, and the weakest page - use it to route low-confidence scans to review |
| `pageCount` `pagesProcessed` `method` | Pages in the file, pages actually processed, and whether OCR, the PDF text layer or a mix was used |
| `wordCount` `charCount` `lineCount` `width` `height` `sizeBytes` `mimeType` | Size and length metrics; image dimensions; the detected file type |
| `languages` `pageSegmentation` `durationMs` | The recognition settings used and the processing time |
| `status` `error` | `ok`, or `failed` with the reason (bad link, not an image/PDF, too large, unreadable) - failures are never charged |

### Input

```json
{
  "imageUrls": [
    "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
    "https://www.irs.gov/pub/irs-prior/f1040--1913.pdf"
  ],
  "languages": ["eng"],
  "pageSegmentation": "auto",
  "preferTextLayer": true,
  "includePageText": true,
  "includeWords": false
}
```

- **Image / PDF URLs** - direct links to image or PDF files, one per line. Leave empty for a small free sample.
- **Import URLs from a file** - paste a whole list, or link a public `.txt`/`.csv`, a Google Sheet/Drive share link, or an Apify key-value-store record. Blank lines, `#` comments, quotes and extra CSV columns all parse; a file that cannot be read says so and charges nothing.
- **Languages** - pick one or more of 28 languages (English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Russian, Ukrainian, Turkish, Arabic, Hebrew, Hindi, Japanese, Korean, Chinese simplified and traditional, Czech, Swedish, Danish, Norwegian, Finnish, Hungarian, Romanian, Vietnamese, Indonesian, Thai). Fewer languages = faster and more accurate.
- **Page layout** - `auto` for ordinary documents; `sparse` for screenshots, receipts and labels; `single_line` for captchas, serial numbers and labels; `single_block` for one clean paragraph; `columns` for single-column text with mixed sizes.
- **Use the PDF text layer when present** - born-digital PDFs are read exactly instead of OCR-ed (default on). Each page reports its `method`.
- **PDF render resolution** - 200 DPI default; 300 for small print; 150 for speed.
- **Include per-page text / Include word boxes** - shape the record for your use case (search index, redaction, form parsing, layout reconstruction).
- **Max pages per PDF** - default 20; set 0 for all pages. **Max file size** - default 30 MB.
- **Output fields** - tick only the fields you want for a lean CSV/Sheets export.

### Example output

```json
{
  "type": "ocr",
  "url": "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
  "filename": "eurotext.png",
  "sourceType": "image",
  "status": "ok",
  "error": null,
  "sizeBytes": 31481,
  "mimeType": "image/png",
  "pageCount": 1,
  "pagesProcessed": 1,
  "method": "ocr",
  "languages": ["eng"],
  "pageSegmentation": "auto",
  "text": "The (quick) [brown] {fox} jumps!\nOver the $43,456.78 <lazy> #90 dog\n& duck/goose, as 12.5% of E-mail\nfrom aspammer@website.com is spam.\n...",
  "wordCount": 68,
  "charCount": 421,
  "lineCount": 8,
  "meanConfidence": 91.4,
  "minPageConfidence": 91.4,
  "width": 1024,
  "height": 480,
  "pages": [{ "page": 1, "method": "ocr", "text": "...", "wordCount": 68, "charCount": 421, "lineCount": 8, "meanConfidence": 91.4 }],
  "durationMs": 1830,
  "scrapedAt": "2026-09-02T06:00:00.000Z"
}
```

### Use cases

- **Digitise scanned archives** - contracts, invoices, receipts, forms, letters, historical records - into searchable text.
- **Invoice / receipt / form data capture** - turn photos and scans into text you can parse with rules or an LLM; use `words[]` boxes to locate fields.
- **Screenshot and image text extraction** - pull text from screenshots, memes, slides, charts, product labels and packaging.
- **Make PDFs searchable** - extract text from scanned PDFs for search indexes, RAG pipelines and knowledge bases; born-digital PDFs are read for free via the text layer.
- **Compliance and review** - route pages under a confidence threshold to a human reviewer using `meanConfidence` / `minPageConfidence`.
- **Multilingual document processing** - 28 languages, combinable for mixed-language documents.

### Tips for the best accuracy

- Scan at 200-300 DPI; photos should be sharp, well-lit and not skewed.
- Choose the exact language(s); adding languages the document does not contain lowers accuracy.
- Use `sparse` layout for receipts, screenshots and labels; `single_line` for one-line labels and codes.
- Check `meanConfidence`: below ~70 usually means a poor scan, the wrong language, or the wrong layout mode.

### Use with AI assistants (MCP)

This actor is available through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp), so assistants like Claude can call it as a tool - "extract the text from these three scanned invoices" or "OCR this screenshot in German" - and get structured text back.

### Agent-ready: autonomous payments (x402 & Skyfire)

This actor is **agent-ready** - AI agents can discover it, run it, and **pay for it autonomously**, with no Apify account and no human in the loop. It uses [pay-per-event](https://docs.apify.com/platform/actors/publishing/monetize/pay-per-event) pricing and [limited permissions](https://docs.apify.com/platform/actors/development/permissions), so it qualifies for Apify's agentic-payment standards:

- **[x402](https://docs.apify.com/platform/integrations/x402)** - an open, HTTP-native payment protocol. Agents pay per run in USDC on the Base network directly through the [Apify MCP server](https://docs.apify.com/platform/integrations/mcp) - no account, no API key.
- **[Skyfire](https://docs.apify.com/platform/integrations/skyfire)** - agent-to-service payments for fully autonomous AI-agent workflows.

Building an AI agent, MCP tool, or autonomous data pipeline? This tool is ready to plug in and pay as it goes.

### Pricing

Pay-per-event, tiered by volume: **$0.003 per page** on the free tier, dropping to **$0.00075 per page** at the top tier. An image is one page; a PDF is charged per page actually processed (text-layer pages included). Failed downloads, unsupported files and unreadable pages are **never charged**.

### FAQ

**Does it work on photos of documents, not just scans?** Yes - sharp, well-lit photos work well. Skew and blur reduce confidence.

**What about handwriting?** Tesseract is built for printed text. Neat handwriting sometimes works; cursive generally does not.

**How are PDFs handled?** Every page is checked for a text layer first. Pages with real text are read exactly (`method: "text-layer"`); scanned pages are rasterised at your DPI and OCR-ed (`method: "ocr"`). A file with both reports `method: "mixed"`.

**Which formats are supported?** PNG, JPEG, TIFF (including multi-page), WEBP, BMP, GIF and PDF. The type is detected from the file itself, not the extension.

**Can I get the position of each word?** Turn on **Include word boxes** to get `words[]` with pixel coordinates and per-word confidence.

**Is there a size limit?** Files over the **Max file size** (default 30 MB) are skipped with a clear error and no charge. Very long PDFs are capped by **Max pages per PDF** (default 20, 0 = all).

**Does it need a proxy?** No. Files are downloaded directly; enable a proxy only if a host blocks the download.

Every run finishes with a clear status message; runs with nothing to process never crash and never bill.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct links to images (PNG, JPG, TIFF, WEBP, BMP, GIF) or PDF files, one per line. Each file is downloaded and recognised. Duplicates are collapsed. <b>Leave empty and the run returns a small free sample.</b>

## `urlsFromFile` (type: `string`):

Bulk-load links. Either <b>paste the whole list</b> (one URL per line), or give <b>a single link</b> to a public <code>.txt</code>/<code>.csv</code>, a Google Sheet or Drive share link, or an Apify key-value-store record. Blank lines, <code>#</code> comments, CRLF, a UTF-8 BOM, quotes and extra CSV columns all parse. A file that cannot be read says so and charges nothing.

## `languages` (type: `array`):

Language(s) of the text. Pick more than one for mixed documents (they are combined, e.g. English + German). Fewer languages = faster and more accurate.

## `pageSegmentation` (type: `string`):

How Tesseract should read the page. <b>Automatic</b> handles most documents. Use <b>sparse</b> for screenshots, receipts and labels with scattered text, <b>single\_line</b> for captchas/labels/serial numbers, <b>single\_block</b> for a clean paragraph.

## `preferTextLayer` (type: `boolean`):

For PDFs that already contain selectable text (born-digital documents), read that text directly instead of rendering and OCR-ing the page - exact and much faster. Pages without a text layer (scans) are always OCR-ed. Each page reports which method was used.

## `dpi` (type: `integer`):

Resolution used to rasterise PDF pages before OCR. 200 is a good default; 300 helps small print, 150 is faster for clean large text.

## `includePageText` (type: `boolean`):

Add a <code>pages\[]</code> array with each page's text, word count, confidence and method, on top of the concatenated <code>text</code>. Turn off for a leaner record.

## `includeWords` (type: `boolean`):

Add a <code>words\[]</code> array with every recognised word, its confidence (0-100) and bounding box (left, top, width, height in pixels of the recognised image). Useful for highlighting, redaction, form parsing and layout reconstruction. Increases record size.

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

Cap how many pages to process per PDF (you are charged per page). 0 = all pages. Images always count as one page.

## `outputFields` (type: `array`):

Pick the fields you want and every record is trimmed to exactly those - handy for lean CSV/Sheets exports. Open the dropdown and tick, or start typing to filter.

## `maxItems` (type: `integer`):

Maximum number of files to process in one run (after de-duplication).

## `maxFileMb` (type: `integer`):

Skip any file larger than this. A skipped file is reported with an error and never charged.

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

Optional. Files are downloaded directly by default. Enable a proxy only if a host blocks the downloader (e.g. returns 403). OCR itself runs inside the actor and needs no proxy.

## Actor input object example

```json
{
  "imageUrls": [
    "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "languages": [
    "eng"
  ],
  "pageSegmentation": "auto",
  "preferTextLayer": true,
  "dpi": 200,
  "includePageText": true,
  "includeWords": false,
  "maxPagesPerPdf": 20,
  "maxItems": 100,
  "maxFileMb": 30
}
```

# Actor output Schema

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

All OCR document records as JSON items in the default dataset.

# 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 = {
    "imageUrls": [
        "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    ],
    "urlsFromFile": "",
    "languages": [
        "eng"
    ],
    "pageSegmentation": "auto",
    "dpi": 200
};

// Run the Actor and wait for it to finish
const run = await client.actor("scrapesage/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 = {
    "imageUrls": [
        "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
    ],
    "urlsFromFile": "",
    "languages": ["eng"],
    "pageSegmentation": "auto",
    "dpi": 200,
}

# Run the Actor and wait for it to finish
run = client.actor("scrapesage/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 '{
  "imageUrls": [
    "https://tesseract-ocr.github.io/tessdoc/images/eurotext.png",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "urlsFromFile": "",
  "languages": [
    "eng"
  ],
  "pageSegmentation": "auto",
  "dpi": 200
}' |
apify call scrapesage/ocr-text-extractor --silent --output-dataset

```

## MCP server setup

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