# Image and Scanned PDF OCR (Arabic, Cyrillic, Hindi, Latin) (`opstoolkit/image-pdf-ocr`) Actor

Give it image or scanned PDF links, get the text of each page as JSON with line confidence and boxes. OCR for English, Arabic, Russian, Hindi, French, Spanish, German. AI mode turns receipts and invoices into JSON. From $1.50 per 1,000 pages.

- **URL**: https://apify.com/opstoolkit/image-pdf-ocr.md
- **Developed by:** [Elio Saliba](https://apify.com/opstoolkit) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 ocr page (ai mode)s

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

## Image OCR (Arabic, Cyrillic, Latin, Hindi) and Scanned PDF to Text

Give it links to images or scanned PDFs and get the text back as JSON: one row per image or PDF page, in reading order, with every line's confidence and position. An optional AI mode reads handwriting and returns receipts, invoices and forms as JSON that follows a schema you write.

Built for accountants and bookkeepers with receipt photos, researchers with archive scans, AI teams that need scanned PDFs as text, and n8n or Make flows that post an image link and want text back. English, Arabic, Russian, Hindi, French, Spanish and German work in the free engine.

**$1.50 per 1,000 pages** with the free engine. **$3.00 per 1,000 pages** in AI mode, plus the AI model usage Apify bills to your account (about $0.40 per 1,000 pages on a paid plan). Pages with no text, broken links and files that are too big are free.

### What you get

One row per image, and one row per page for PDFs and multi-page TIFFs.

| Column | Example | Notes |
|---|---|---|
| `url`, `page`, `pageCount` | `.../scan.pdf`, `2`, `14` | Pages are numbered from 1 |
| `status` | `ok` | `ok`, `no_text`, `unreachable`, `not_image`, `too_large`, `invalid_input`, `skipped_page_limit`, `skipped_max_cost` or `error`. Only `ok` is charged |
| `text` | `A TEXT-BOOK OF AGRICULTURAL ENTOMOLOGY...` | Text in reading order, a blank line between blocks |
| `lines` | `[{"text": "BY", "confidence": 0.93, "box": [520, 1085, 575, 1120]}]` | Confidence is 0 to 1. Boxes are pixels on the upright page image, left, top, right, bottom |
| `script` | `latin` | Detected from the text itself: latin, arabic, cyrillic, devanagari and so on |
| `avgConfidence`, `lowConfidence` | `0.91`, `false` | Average over the page. `lowConfidence` is true under 0.6 |
| `engine` | `tesseract` | `tesseract`, `pdf-text` (text already inside the PDF) or `ai` |
| `languages`, `rotation`, `width`, `height` | `eng+fra+spa+deu`, `0`, `1685`, `2745` | What the free engine used. Rotation is the turn that was applied |
| `structured` | `{"vendor": "Cafe Roma", "total": 18.5}` | AI mode with a schema |
| `charged` | `ocr-page` | The event charged for this row, or `null` |
| `reason`, `warnings` | | A plain reason for every free row |
| `aiUsage` | `{"inputTokens": 1240, "outputTokens": 310, "openRouterCostUsd": 0.0003}` | AI mode only |
| `textFile` | | Download link, when `saveTextFiles` is on |

### How to use

1. **Add your files.** Paste direct links to PNG, JPEG, WebP, TIFF, GIF, BMP or PDF files, upload files, or give the ID of a dataset and the field that holds the links (for example the output of Bulk Image Downloader).
2. **Pick the engine.** Free engine only, AI only, or Auto (free engine first, AI for pages it is unsure about).
3. **Press Start.** One page takes a few seconds to about half a minute, depending on how dense it is and how much memory you give the run.

### Use it from an AI agent

In Claude, ChatGPT or Cursor, add the Apify MCP server (https://mcp.apify.com) and ask the agent to run this Actor. It needs only a direct file link, and `engine`, `languages` and `schema` are plain fields the agent can set from your sentence.

Example prompt: "Use the Apify Actor opstoolkit/image-pdf-ocr on https://example.com/receipts/2026-11-03.jpg with the AI engine, and return vendor, date and total as JSON."

### Input example

```json
{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg"
  ],
  "engine": "fast",
  "languages": [],
  "outputFormat": "lines",
  "pdfMaxPages": 50
}
```

A receipt to JSON, with the AI model:

```json
{
  "urls": ["https://example.com/receipts/2026-11-03.jpg"],
  "engine": "ai",
  "schema": {
    "type": "object",
    "properties": {
      "vendor": {"type": "string"},
      "date": {"type": "string"},
      "total": {"type": "number"},
      "items": {"type": "array", "items": {"type": "object", "properties": {"name": {"type": "string"}, "price": {"type": "number"}}}}
    }
  }
}
```

### Output example

```json
{
  "url": "https://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg",
  "fileType": "jpeg",
  "page": 1,
  "pageCount": 1,
  "status": "ok",
  "text": "AGRICULTURAL ENTOMOLOGY;\n\nBEING\n...",
  "script": "latin",
  "engine": "tesseract",
  "charged": "ocr-page"
}
```

### Which engine

| | Free engine | AI mode |
|---|---|---|
| What reads the page | Tesseract 5 (open source), run inside the Actor | A Gemini vision model |
| Good at | Printed text, scans, book pages, forms, 7 languages | Handwriting, photos at an angle, tables, stylised text, any script, JSON from a schema |
| Gives you | Text, line confidence, line boxes | Text, or the JSON you asked for |
| Price per page | $0.0015 | $0.003 plus about $0.0004 model usage |
| Where the image goes | Nowhere, it stays in the Actor | To Google, through Apify's OpenRouter proxy |

**Auto** reads every page with the free engine and sends only the pages under 60% confidence to the AI model. Those pages are charged as AI pages, not twice.

### Languages and scripts

The free engine has models for English, Arabic, Russian, Hindi, French, Spanish and German. With no language set, it detects the page's script first (Latin, Arabic, Cyrillic or Devanagari) and picks the matching models. Latin pages are read as English, French, Spanish and German together.

Setting `languages` yourself is faster and a little more accurate. Pages in other scripts (Chinese, Japanese, Korean, Thai, Greek) are not covered by the free engine. Use AI mode for those.

### Scanned PDFs

PDF pages are rendered at 200 dpi and read one by one. If a page already has selectable text inside the PDF, that text is returned as it is (`engine: pdf-text`) instead of re-reading a picture of it. It is still charged as a page. Turn this off with `usePdfTextLayer` if you want every page read from its picture.

Up to 50 pages per file by default (`pdfMaxPages`, up to 500). Pages beyond the limit come back as one free row that says which pages were skipped.

### Pricing

Pay per event.

| Event | Price | When |
|---|---|---|
| `ocr-page` | $0.0015 | One image or PDF page with text found, free engine or text already in the PDF |
| `ocr-page-ai` | $0.003 | One image or PDF page read by the AI model |

| Pages | Free engine | AI mode, this Actor | AI mode, model usage (paid plan, approx.) |
|---|---|---|---|
| 100 | $0.15 | $0.30 | $0.04 |
| 1,000 | $1.50 | $3.00 | $0.40 |
| 10,000 | $15.00 | $30.00 | $4.00 |

- Pages with no text, links that fail, files over the size limit, pages past `pdfMaxPages` and pages skipped at your max cost are free rows with a reason.
- A page is charged only after it has been read. If the AI model fails on a page in Auto mode, the free result is kept and charged as a normal page.
- The run stops cleanly when your max cost per run is reached. The rest of a PDF comes back as one free row, nothing is read and thrown away.
- The max cost per run covers this Actor's price. The AI model usage is a separate line on your Apify bill. Free-plan accounts pay 10 times the OpenRouter price for it.

### What it will not read

Direct file links only. A link to a web page is refused with a free row, the Actor does not crawl sites. Links to private or internal addresses are refused. Password-protected PDFs are refused. Only OCR documents you have the right to process, and remember that receipts, forms and ID-like documents can hold personal data.

### Limits

- Files up to 25 MB by default (`maxFileSizeMb`, up to 100). Images up to 100 million pixels.
- Printed text only for the free engine. Handwriting, very stylised fonts and low-resolution photos give low confidence. Try AI mode on those pages.
- Tesseract gives line and word positions, not table structure. For tables use AI mode, which writes each row on one line with cells separated by `|`.
- The AI model's answer is capped at about 2,000 tokens per page. A very dense page can come back cut off, and the row carries the `ai_answer_cut_off` warning.
- In schema mode the AI returns the structured data only, not the page text.
- The default memory is 1 GB. Very large PDFs or high-resolution scans may need 2 GB.

### Privacy

In free mode nothing leaves the Actor. In AI mode the page image goes to Google Gemini through Apify's OpenRouter proxy, which only uses zero-data-retention endpoints. The Actor deletes its temporary files when the run ends. Results stay in your run's storage under your Apify retention settings.

### Works well with

- [Bulk Image Downloader](https://apify.com/opstoolkit/bulk-image-downloader): download the images from a page, then pass its dataset ID as `datasetId` and set `urlField` to `imageUrl` to read the text on them.
- [Document to Markdown for AI](https://apify.com/opstoolkit/document-to-markdown-rag): PDFs with a text layer go there. Scanned PDFs come here first.
- [AI Structured Extractor](https://apify.com/opstoolkit/ai-structured-extractor): set its `datasetId` to this run's dataset and `field` to `text` to pull named fields (invoice number, date, total) out of the OCR text.
- [Dataset Cleaner](https://apify.com/opstoolkit/dataset-cleaner): clean the final rows. Turn on "Flatten nested objects" so `structured.vendor` and `structured.total` become columns, then fix dates and drop duplicate receipts.

A typical chain: Bulk Image Downloader, then this Actor, then AI Structured Extractor, then Dataset Cleaner. Schedules, webhooks, the REST API, Zapier, Make and n8n all work.

### FAQ

**Can it read handwriting?**
Use AI mode. The free engine is built for printed text.

**Why did a page come back as `no_text`?**
The engine found nothing readable, so it is free. Blank pages, photos without text and very faint scans do this. Try AI mode on a faint scan.

**Can it return a receipt as JSON?**
Yes, in AI mode. Write the fields you want as a JSON schema in `schema`.

**Does it keep my files?**
No. It deletes them when the run ends.

**Something broke.**
Open an issue on the Issues tab with the run link. I reply within a day.

# Actor input Schema

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

Direct links to image or PDF files, one per item. Accepted: PNG, JPEG, WebP, TIFF, GIF, BMP, PDF. Example: \["https://example.com/scans/invoice-2026-11.pdf"]. A link to a web page is refused as a free row, the Actor does not crawl sites. Give at least one of urls, files or datasetId. Only OCR files you have the right to process.

## `files` (type: `array`):

Images or PDFs uploaded from your computer in the Apify Console. They are stored in your key-value store and read with this run's token. Use this or urls. Leave empty when calling the Actor from the API or an AI agent, and pass urls instead.

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

Optional. The ID of an Apify dataset whose rows hold image or PDF links, for example the output of Bulk Image Downloader. Example: "aBcDeFgHiJkLmNoPq". Every row's link (field set in urlField) is read. Leave empty if you pass urls or files.

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

Name of the field in each dataset row that holds the image or PDF link. Only used with datasetId. Use dots for nested fields, for example media.url. Default: url.

## `engine` (type: `string`):

How pages are read. auto: free engine first, AI only for pages under 60% confident (those are billed as AI pages). fast: free engine only, printed text in 7 languages, keeps line confidence and boxes. ai: Gemini vision model, for handwriting, photos at an angle, tables, other scripts and JSON from a schema. A schema cannot be used with fast. Default: auto.

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

Languages to read, one per item. Accepted codes: eng, ara, rus, hin, fra, spa, deu (English, Arabic, Russian, Hindi, French, Spanish, German). Names like English or two-letter codes like fr also work. Example: \["ara", "eng"]. Leave empty to detect the script of each page. Setting it is faster and more accurate. Free engine only.

## `minConfidence` (type: `string`):

Free engine only. Lines the engine is less sure about than this value are dropped from the text. A number from 0 to 1 written as text, for example "0.5". Use "0" to keep every line. Default: "0.3".

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

How much each row carries. text: the page text only. lines: text plus every line with its confidence (0 to 1). boxes: lines with pixel boxes as well (left, top, right, bottom). Default: lines.

## `autoRotate` (type: `boolean`):

When true, the free engine detects the page rotation and turns the page upright before reading. Set false if a page is already upright and you want it read as is. Default: true.

## `schema` (type: `object`):

Optional. A JSON schema object with the fields you want back, for example {"type":"object","properties":{"vendor":{"type":"string"},"date":{"type":"string"},"total":{"type":"number"}}}. The AI model fills it in and the result goes in the structured field. Setting it switches the engine to AI (not allowed with fast), turns off the PDF text layer, and the page text is not returned. Leave empty for plain OCR.

## `aiModel` (type: `string`):

Vision model used in AI mode, one of google/gemini-3.5-flash-lite (default, cheapest), google/gemini-3.1-flash-lite, google/gemini-3.6-flash (most accurate on hard pages). Reached through Apify's OpenRouter proxy. Its usage is billed to your Apify account at OpenRouter's price, on top of this Actor's price. Ignored when the free engine reads the page.

## `pdfMaxPages` (type: `integer`):

Most pages to read from each PDF or multi-page TIFF. A whole number from 1 to 500, for example 20. Pages after this number are not read and come back as one free row. Default: 50.

## `usePdfTextLayer` (type: `boolean`):

When true, a PDF page that already has selectable text is returned as it is (engine pdf-text) instead of being re-read from a picture. It is still charged as a page. Set false to read every page from its picture. Default: true.

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

When true, the text of each file is saved as a .txt in the run's key-value store and the download link is put in the textFile field of each row. Default: false.

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

Largest file size accepted, in megabytes. A whole number from 1 to 100, for example 40. Bigger files are refused as a free row. Raise it for large PDFs and give the run more memory (2 GB or more). Default: 25.

## Actor input object example

```json
{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg"
  ],
  "urlField": "url",
  "engine": "fast",
  "minConfidence": "0.3",
  "outputFormat": "lines",
  "autoRotate": true,
  "aiModel": "google/gemini-3.5-flash-lite",
  "pdfMaxPages": 50,
  "usePdfTextLayer": true,
  "saveTextFiles": false,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `pages` (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 = {
    "urls": [
        "https://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg"
    ],
    "engine": "fast"
};

// Run the Actor and wait for it to finish
const run = await client.actor("opstoolkit/image-pdf-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://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg"],
    "engine": "fast",
}

# Run the Actor and wait for it to finish
run = client.actor("opstoolkit/image-pdf-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://upload.wikimedia.org/wikipedia/commons/8/8e/A_text-book_of_agricultural_entomology_BHL9798241.jpg"
  ],
  "engine": "fast"
}' |
apify call opstoolkit/image-pdf-ocr --silent --output-dataset

```

## MCP server setup

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