# OCR Image to Text & Scanned PDF to Text (Tesseract, 100+ langs) (`gmyri/image-pdf-ocr`) Actor

OCR API: extract text from images (PNG, JPEG, TIFF, WebP) and scanned PDFs with Tesseract 5. 100+ languages, confidence scores and Markdown for LLM/RAG. $2 per 1,000 pages.

- **URL**: https://apify.com/gmyri/image-pdf-ocr.md
- **Developed by:** [Giorgos Myrianthous](https://apify.com/gmyri) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 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.

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 Image to Text & Scanned PDF to Text (Tesseract, 100+ langs)

**OCR image to text** and **scanned PDF to text** with Tesseract 5: 100+ languages, multi-page TIFF and PDF, per-page confidence, and Markdown output for LLM and RAG pipelines. No third-party API key needed.

💲 **$2 per 1,000 pages.** Pages that already contain PDF text (optional) and failed files are free. Pay only for results. No subscription, and the Apify free plan's monthly credit covers small jobs.

**Also known as:** OCR, image to text, scanned PDF to text, PDF OCR, extract text from image, Tesseract OCR API, screenshot to text, TIFF to text.

### Try it now (free-plan friendly)

1. Click **Start**. The prefilled input works as is. Runs OCR on a sample scanned image from the Tesseract test set in a few seconds.
2. Or paste this input into the JSON tab:

```json
{
  "fileUrls": [
    {
      "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    }
  ],
  "languages": [
    "eng"
  ]
}
```

**Example output** (one dataset item, shortened):

```json
{
  "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
  "status": "ok",
  "pages": 1,
  "meanConfidence": 95.0,
  "wordCount": 60,
  "text": "This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof file format. …"
}
```

Small runs cost cents, and you can set a **Max cost per run** so you're never charged more.

### Use with AI agents / Apify MCP

Give your agent (Claude, ChatGPT, Cursor, n8n AI Agent, LangChain, OpenAI Agents SDK) this tool through **Apify's MCP server**:

```text
https://mcp.apify.com?tools=gmyri/image-pdf-ocr
```

- **Example prompt:** "Extract the text from this scanned PDF: https://..."
- **Why agents like it:** the input has one required field and documented defaults and enums. The output has stable, flat field names, errors are returned as items with an `error` field and are never charged, and each run writes a summary to the `OUTPUT` record.
- Agents that use `search-actors` find it by searching for: OCR, image to text.

### API, Python, n8n, Make, Zapier

```bash
curl -X POST "https://api.apify.com/v2/acts/gmyri~image-pdf-ocr/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"fileUrls":[{"url":"https://example.com/scan.pdf"}],"languages":["eng"]}'
```

- **Python:** `ApifyClient(token).actor("gmyri/image-pdf-ocr").call(run_input={...})`
- **n8n / Make / Zapier:** use the Apify "Run Actor" action with `gmyri/image-pdf-ocr`, then read the dataset items.

### Quick FAQ

- **Digital (non-scanned) PDFs?** Turn on `useEmbeddedTextIfPresent` (those pages are free), or use [PDF to Markdown](https://apify.com/gmyri/doc-to-markdown) for Word, Excel and PowerPoint as well.
- **What if I set a spending limit?** The Actor stops cleanly at your *Max cost per run* and you're never charged above it.

### Details

Turn **images and scanned PDFs into text** with Tesseract OCR 5. It takes PNG, JPEG, TIFF (including multi-page), WebP, BMP, GIF and PDF from any public or signed URL, and returns clean text, **Markdown with page markers** for LLM/RAG pipelines, and a confidence score per page.

**$2 per 1,000 pages.** Failed files are free, and pages that already have embedded PDF text can be taken for free.

### Why this OCR Actor

- **100+ languages.** English, German, French, Spanish, Italian, Portuguese and Dutch are pre-installed. Any other [Tesseract language](https://tesseract-ocr.github.io/tessdoc/Data-Files-in-different-versions.html) (Polish, Greek, Russian, Ukrainian, Arabic, Hindi, Chinese, Japanese, Korean…) is fetched automatically from the official repository. Combine languages for mixed documents (`["eng","deu"]`).
- **Scanned PDFs.** Each page is rendered at 300 DPI (configurable) and OCRed. Long PDFs are capped by `maxPagesPerFile`.
- **Hybrid PDFs.** With `useEmbeddedTextIfPresent`, pages that already contain text use it **for free**, and only image pages are OCRed.
- **Quality pre-processing.** Fixes EXIF rotation, converts to grayscale, upscales small images and applies auto-contrast.
- **Confidence scores** per page and per file, so you can route low-confidence pages to human review.
- **Private and simple.** It runs in your Apify account. No third-party OCR API or key is needed.

### Typical uses

- Make scanned contracts, invoices, letters and archives searchable
- Feed **RAG / vector databases** and AI agents with text from image-only documents
- Extract text from screenshots, slides, signs and product photos (use `pageSegmentationMode: "11"`)
- Pair it with [Document to Markdown](https://apify.com/gmyri/doc-to-markdown) for digital PDFs, DOCX and PPTX

### Input example

```json
{
  "fileUrls": [
    { "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif" },
    { "url": "https://example.com/scanned-contract.pdf" }
  ],
  "languages": ["eng"],
  "pdfDpi": 300,
  "maxPagesPerFile": 50,
  "useEmbeddedTextIfPresent": false
}
```

| Field | Default | What it does |
|---|---|---|
| `fileUrls` | – | Image or PDF URLs |
| `languages` | `["eng"]` | Tesseract language codes (combine for mixed documents) |
| `pdfDpi` | 300 | PDF render resolution (200 is faster, 300 more accurate) |
| `maxPagesPerFile` | 50 | Page cap per PDF/TIFF |
| `useEmbeddedTextIfPresent` | `false` | Use the PDF text layer when present (free pages) |
| `pageSegmentationMode` | `"3"` | `3` auto, `4` column, `6` block, `11` sparse text, `12` sparse + orientation |
| `outputPages` | `true` | Include per-page text and confidence |
| `maxFileSizeMb` | 50 | Skip larger files |
| `requestTimeoutSecs` | 60 | Download timeout |

### Output (one item per file)

```json
{
  "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
  "status": "ok", "fileType": "image", "languages": "eng",
  "pages": 1, "totalPages": null, "truncated": false,
  "meanConfidence": 95.0, "wordCount": 60,
  "text": "This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof file format. …",
  "markdown": "<!-- page 1 -->\n\nThis is a lot of 12 point text …",
  "pageResults": [{ "page": 1, "text": "…", "confidence": 95.0, "source": "ocr", "widthPx": 1280, "heightPx": 1600 }],
  "error": null
}
```

### Pricing (pay per event)

| Event | Price |
|---|---|
| Page OCRed (primary) | **$0.002** ($2 / 1,000 pages) |
| Actor start | $0.00005 per run (Apify default) |

Pages read from an embedded PDF text layer, and failed files, are **not charged**. Platform usage is included, and the Actor stops cleanly at your **Max cost per run**.

### Use from AI agents (MCP), n8n, Make, Zapier and the API

- **MCP:** add `gmyri/image-pdf-ocr` to the [Apify MCP server](https://mcp.apify.com). Agents pass file URLs and get text back.
- **n8n / Make / Zapier:** upload the file to cloud storage, pass its (signed) URL to "Run Actor", then read `text` or `markdown` from the dataset.
- **API:**
  ```bash
  curl -X POST "https://api.apify.com/v2/acts/gmyri~image-pdf-ocr/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
    -H 'Content-Type: application/json' -d '{"fileUrls":[{"url":"https://…/scan.png"}],"languages":["eng"]}'
  ```

### FAQ

**How accurate is it?** On clean scans at 300 DPI, Tesseract usually reaches 95%+ word accuracy. Photos, handwriting and low-resolution images do worse. Check `meanConfidence`.

**Does it read handwriting?** Not reliably. Tesseract is built for printed text.

**Are my files stored?** Files are downloaded into the run container, processed and discarded. Only the extracted text is saved, in your run's dataset.

### Related tools

- [PDF to Markdown & Text Converter: Word, Excel, PPT, HTML, RAG](https://apify.com/gmyri/doc-to-markdown)
- [Website Screenshot API: Full Page, Mobile & URL to PDF](https://apify.com/gmyri/website-screenshot)
- [Merge & Deduplicate Datasets: Remove Duplicates, Only New Items](https://apify.com/gmyri/dataset-merge-dedup)
- [Website Audit All-in-One: SEO, PageSpeed, Broken Links, SSL](https://apify.com/gmyri/website-audit)

💡 **Need several checks per site?** [Website Audit All-in-One](https://apify.com/gmyri/website-audit) runs SEO, broken links, PageSpeed, tech stack and SSL/DNS checks in one report for $0.03 per site.

All tools by gmyri: [doc-to-markdown](https://apify.com/gmyri/doc-to-markdown), [dataset-merge-dedup](https://apify.com/gmyri/dataset-merge-dedup), [site-health-audit](https://apify.com/gmyri/site-health-audit), [website-screenshot](https://apify.com/gmyri/website-screenshot), [domain-health-check](https://apify.com/gmyri/domain-health-check), [tech-stack-detector](https://apify.com/gmyri/tech-stack-detector), [rss-feed-reader](https://apify.com/gmyri/rss-feed-reader), [pagespeed-checker](https://apify.com/gmyri/pagespeed-checker), [website-audit](https://apify.com/gmyri/website-audit).

# Actor input Schema

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

Public URLs of images (PNG, JPEG, TIFF incl. multi-page, WebP, BMP, GIF) or PDFs (scanned or not). Signed cloud-storage links (S3, GCS, Dropbox, Apify key-value store) work too.

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

Tesseract language codes, e.g. eng, deu, fra, spa, ita, por, nld, pol, rus, ukr, ell, tur, ara, hin, jpn, kor, chi_sim, chi_tra. Combine several for mixed documents. Models not pre-installed are downloaded from the official tessdata_fast repository on first use.

## `pdfDpi` (type: `integer`):

Resolution used to rasterise PDF pages before OCR. 300 is the accuracy sweet spot; 200 is faster.

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

Stop after this many pages of one PDF/TIFF (the item is marked truncated).

## `useEmbeddedTextIfPresent` (type: `boolean`):

For PDFs that already have a text layer, take that text instead of running OCR. Those pages are not charged. Turn off to force OCR on every page.

## `pageSegmentationMode` (type: `string`):

Tesseract layout analysis mode. Use 11 for screenshots, receipts or photos with scattered text.

## `outputPages` (type: `boolean`):

Add a pageResults array (text and confidence per page) to each item.

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

Larger files are skipped (not charged).

## `requestTimeoutSecs` (type: `integer`):

Timeout for downloading each file.

## Actor input object example

```json
{
  "fileUrls": [
    {
      "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    }
  ],
  "languages": [
    "eng"
  ],
  "pdfDpi": 300,
  "maxPagesPerFile": 50,
  "useEmbeddedTextIfPresent": false,
  "pageSegmentationMode": "3",
  "outputPages": true,
  "maxFileSizeMb": 50,
  "requestTimeoutSecs": 60
}
```

# Actor output Schema

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

One item per file: full text, Markdown with page markers, confidence and per-page results.

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

OUTPUT record: files, pages OCRed, pages from text layer, failures.

# 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 = {
    "fileUrls": [
        {
            "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gmyri/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 = { "fileUrls": [{ "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif" }] }

# Run the Actor and wait for it to finish
run = client.actor("gmyri/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 '{
  "fileUrls": [
    {
      "url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    }
  ]
}' |
apify call gmyri/image-pdf-ocr --silent --output-dataset

```

## MCP server setup

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