# OCR: Extract Text from Images & Scanned PDFs (100+ Languages) (`squarish_altruism/ocr`) Actor

Extract text from images (JPG, PNG, WebP, TIFF, HEIC) and scanned PDFs with Tesseract OCR in 100+ languages. Digital PDF pages are read from their text layer at a lower price. Per-page text and confidence.

- **URL**: https://apify.com/squarish_altruism/ocr.md
- **Developed by:** [John Joseph Wheatley](https://apify.com/squarish_altruism) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per event

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

## OCR: Extract Text from Images & Scanned PDFs (100+ Languages)

> **At a glance:** extract text from images and scanned PDFs in 100+ languages. **You get** the text and a confidence score per page. **Cost:** 1,000 scanned pages are $2.

Turn **images and scanned PDFs into text**. Paste links to photos, screenshots, receipts, invoices, forms or scanned documents, and get the extracted text with a confidence score per page.

- **Images:** JPG, PNG, WebP, TIFF, GIF, HEIC and AVIF. EXIF orientation is corrected automatically.
- **PDFs:** in *Auto* mode, pages that already contain digital text are read directly from the PDF's text layer, which is fast, exact and cheaper. Only scanned pages are OCR'd, so mixed documents are handled correctly.
- **100+ languages,** including several at once (e.g. `eng` + `deu`), powered by the open-source [Tesseract](https://github.com/tesseract-ocr/tesseract) engine.
- **Per-page results:** each page's text, the method used (OCR or text layer) and confidence. You can also save `.txt` files.
- **Private by design:** no third-party AI or OCR service sees your documents. Everything runs inside the Actor.

### Use cases

- **Receipts and invoices:** pull totals and line items into a spreadsheet or accounting workflow.
- **Scanned archives:** make old scanned PDFs searchable, or feed them into an LLM or RAG pipeline.
- **Screenshots:** extract text from UI screenshots, slides or social media images.
- **Forms and IDs:** read printed text from forms you're authorised to process.
- **Pair with other tools:** combine with our *Document to Markdown* Actor for digital PDFs, Word and PowerPoint files, and use this one for scans.

### Input

```json
{
  "sources": [
    { "url": "https://example.com/scans/contract.pdf" },
    { "url": "https://example.com/receipt.jpg" }
  ],
  "languages": ["eng", "deu"],
  "pdfMode": "auto",
  "includePages": true
}
```

### Output

One row per document:

```json
{
  "url": "https://example.com/receipt.jpg",
  "type": "image",
  "pagesProcessed": 1,
  "ocrPages": 1,
  "textLayerPages": 0,
  "averageConfidence": 89,
  "words": 14,
  "text": "RECEIPT No. 00431\nCoffee beans 1kg ........ 24.90\nDelivery ................ 4.50\nTOTAL EUR 29.40",
  "pages": [{ "page": 1, "method": "ocr", "confidence": 89, "text": "RECEIPT No. 00431 …" }]
}
```

### Pricing

- **$0.002 per OCR page.** Each image counts as one page.
- **$0.0005 per PDF page read from its text layer,** when no OCR is needed.

1,000 scanned pages cost $2. Failed downloads, unsupported files and pages beyond your limit are free.

### Tips for best results

- **Image quality:** for scans, 200–300 DPI works best. Very small or blurry text lowers confidence.
- **Languages:** choose the document's language for best accuracy. Each extra language slows OCR a little.
- **Handwriting:** Tesseract is designed for printed text, so handwriting is recognised poorly.
- **Layout:** columns and tables come out as text lines in reading order, not as a structured table.

### Use with AI agents (MCP)

This Actor works as a tool for AI assistants such as Claude, ChatGPT and Cursor, through [Apify's MCP server](https://mcp.apify.com).

1. Add the server to your MCP client, with this Actor selected:

```json
{
  "mcpServers": {
    "apify": { "url": "https://mcp.apify.com?tools=squarish_altruism/ocr" }
  }
}
```

In Claude Code: `claude mcp add apify "https://mcp.apify.com?tools=squarish_altruism/ocr" -t http`

2. Sign in with your Apify account when your client asks. If it can't use OAuth, send your Apify API token in an `Authorization: Bearer` header.
3. Ask in plain language, for example: *"Extract the text from this scanned PDF: https://example.com/scan.pdf"*

Runs started by an agent are billed to your Apify account at the same prices as above.

### Related tools

- [Document to Markdown for LLMs](https://apify.com/squarish_altruism/doc-to-markdown)
- [Audio & Video Transcription](https://apify.com/squarish_altruism/transcribe)
- [Bulk Image Downloader & Converter](https://apify.com/squarish_altruism/image-downloader)

# Actor input Schema

## `sources` (type: `array`):

Direct links to images (JPG, PNG, WebP, TIFF, GIF, HEIC/AVIF) or PDF files.

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

Tesseract language codes, e.g. eng, deu, fra, spa, ita, por, nld, pol, rus, ukr, tur, ara, hin, jpn, chi_sim, kor. Use several for mixed-language documents (slower).

## `pdfMode` (type: `string`):

Auto: pages that already contain digital text are read directly (fast, cheaper); only scanned pages are OCR-ed. OCR all: run OCR on every page.

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

Pages beyond this are skipped (not charged).

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

Add a list with text, method and confidence for each page.

## `saveTextFiles` (type: `boolean`):

Save each document's text as a .txt file and add a download link.

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

Larger files are skipped (not charged).

## `workers` (type: `integer`):

Parallel OCR engines (more needs more memory; 2 suits 2 GB).

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
    }
  ],
  "languages": [
    "eng"
  ],
  "pdfMode": "auto",
  "maxPagesPerDocument": 200,
  "includePages": true,
  "saveTextFiles": false,
  "maxFileSizeMb": 50,
  "workers": 2
}
```

# Actor output Schema

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

One item per image or document.

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

Files saved to the run's default key-value store.

# 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 = {
    "sources": [
        {
            "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("squarish_altruism/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 = { "sources": [{ "url": "https://tesseract.projectnaptha.com/img/eng_bw.png" }] }

# Run the Actor and wait for it to finish
run = client.actor("squarish_altruism/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 '{
  "sources": [
    {
      "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
    }
  ]
}' |
apify call squarish_altruism/ocr --silent --output-dataset

```

## MCP server setup

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