# Image & PDF to Text OCR: Tesseract for Screenshots, Receipts (`siteacs/image-ocr`) Actor

Image to text and PDF to text OCR with Tesseract: extract text from images, screenshots, receipts, invoices and scanned PDFs in bulk, in 44 languages including Chinese, Japanese and Arabic. Plain text, word boxes, hOCR or TSV. Failed files are free.

- **URL**: https://apify.com/siteacs/image-ocr.md
- **Developed by:** [SiteAcs](https://apify.com/siteacs) (community)
- **Categories:** Developer tools, Automation, Business
- **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

## Image & PDF to Text OCR: Tesseract for Screenshots, Receipts

Extract the text from images, screenshots, receipts, invoices and PDFs with **Tesseract OCR**, in bulk and in 44
languages (Chinese, Japanese, Korean, Arabic, Hindi and Russian among them). Give it image or PDF URLs, records in an
Apify key-value store, or a URL field of a dataset; get one row per image or PDF page with the `text`, Tesseract's
`meanConfidence` (0-100) and the `wordCount`, and on request every word with its box (`words`), hOCR or TSV.

- **$2.50 per 1,000 images** or scanned PDF pages read by OCR; **$0.50 per 1,000 PDF pages that already contain
  text** (taken from the PDF itself, no OCR). Files that fail to download, are not images, are too large or cannot
  be read are **free**.
- **Read inside the run:** Tesseract 5.5 runs in the actor's container. Your files go to no other OCR service and are
  not kept after the run.
- **Preprocessing built in:** pages on their side or upside down are turned, tilted scans straightened, small
  screenshots enlarged, light text on dark backgrounds inverted, and a page that reads badly gets a second pass.

Quick start: paste the file links into "Image or PDF URLs" and pick the languages printed in them.

```json
{
  "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"],
  "languages": ["eng"],
  "pageSegmentationMode": "single_column"
}
```

**With other actors:** point "Dataset" at a scraper's run and "Dataset field" at its image URLs, for example `image`
from [Amazon Best Sellers Scraper](https://apify.com/siteacs/amazon-bestsellers) or
[AliExpress Search Scraper](https://apify.com/siteacs/aliexpress-search) (text on product images), or `thumbnailUrl`
from [YouTube Video Details](https://apify.com/siteacs/youtube-video-details) (text on thumbnails). For the speech in
videos, use [YouTube Transcript Scraper](https://apify.com/siteacs/youtube-transcript-scraper) or
[TikTok Transcript Scraper](https://apify.com/siteacs/tiktok-transcript-scraper) instead.

### What inputs work well (measured)

We ran the actor on Apify over 198 images whose true text we know (results from build 0.1.6), and report the **character error rate (CER)**:
the share of characters wrong, missing or extra against the true text (lower is better; 1% is about one wrong
character in a 100-character line). 180 of the images were generated for the test (text drawn in 13 common fonts,
then blurred, tilted, compressed or faded to look like scans and screenshots); 18 are real photos and scans of receipts and signs
from Wikimedia Commons, transcribed by hand.

| Input | Images | CER | Settings |
| --- | ---: | ---: | --- |
| Clean document text, 12-48 px | 35 | 0.10% | defaults |
| Scanned pages (blur, noise, slight tilt, JPEG) | 30 | 0.65% | defaults |
| Pages on their side, upside down or tilted 3-8° | 20 | 0.05% | defaults |
| Faint or low-contrast text | 20 | 2.14% | defaults |
| Web and app screenshots, light and dark | 25 | 3.14% | defaults |
| Printed receipts | 10 | 3.41% | Layout "Single column" (15.99% with Automatic) |
| Portuguese, Spanish, German, French pages | 24 | 0.00-0.09% | that language selected |
| Chinese (simplified), Japanese pages | 16 | 1.51%, 0.43% | that language selected |
| **Real photos and scans of receipts and signs** | 18 | **26.7%** | defaults |

On our generated pages, printed text on a flat page or a screen reads well: under one wrong character per hundred
on documents and scans, about three per hundred on screenshots, and on receipts with Layout "Single column" (about
16 per hundred with the default layout). **Real photos are much harder.** About one character in four was wrong
across our 18 transcribed real images: flat scans of real receipts came out at under 1% to 16%; phone photos of
signs and receipts, with curved paper, glare, small text in a big scene or decorative fonts, at 17% up to nothing
readable. We also ran 278 more real Wikimedia Commons images with no transcription (bills, menus, notice boards,
labels, at 1,280 px): 63 of them (23%) came back with no text at all, and 99 more read with a mean confidence under
60\. **A page read with no text found is still charged**, so try a few of your own photos before a large run. For
photos, crop to the text, keep the text at least 20 pixels high, and check the result before you rely on it.
Handwriting is not supported: Tesseract reads printed text. These figures are from our test images; your own files
may read better or worse.

### Input

| Field | What it does |
| --- | --- |
| Image or PDF URLs | Links to the files themselves: PNG, JPEG, WebP, GIF, BMP, TIFF (every page), HEIC/HEIF from iPhones, AVIF, PDF. |
| Key-value store | Read images saved in an Apify key-value store, all of them or only some keys or a key prefix. |
| Dataset + Dataset field | Read the image URLs in a field of a dataset, e.g. `imageUrl`, `images` (a list) or `images.url` (nested). |
| Languages | Every language printed in the images (up to 5). English, Portuguese, Spanish, German, French, Italian, Dutch, Polish, Russian, Arabic, Hindi, Chinese, Japanese, Korean and 30 more. |
| Layout | Tesseract's page segmentation mode. **Automatic** for pages, scans and screenshots; **Single column** for receipts and invoices (prices stay on their item's line); **Sparse** for signs and labels. |
| Preprocessing | Orientation fix, straightening, enlarging small images, contrast stretch, second pass for poor pages, black-and-white method, a character whitelist (e.g. digits only). |
| Output | Add words with boxes and confidence, hOCR, or TSV. |
| PDF text layer | **Automatic** (default): a PDF page that already has real text is taken from the PDF (the text the page shows) and charged as a cheap Text page; scanned pages are read by OCR. **Always OCR** reads every page as an image. |
| Limits | Maximum files, pages per PDF or TIFF (20, from the first; the run's status says how many pages past it were not read), PDF resolution (200 DPI), largest file (50 MB), largest image (60 megapixels). Pages over 5,000 px on their longer side are shrunk to 5,000 px before reading. |

Example input (a receipt, with every word and its box):

```json
{
  "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"],
  "languages": ["eng"],
  "pageSegmentationMode": "single_column",
  "includeWords": true
}
```

### Output

One row per image, and one per PDF or TIFF page:

```json
{
  "index": 0,
  "source": "https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg",
  "page": null,
  "pageCount": null,
  "ok": true,
  "charged": true,
  "method": "ocr",
  "language": "eng",
  "text": "PSI #3076\n1935 E Katella Ave\nOrange, CA 92668\n\nInvoice # 938870\nDate 09/16/03\n...\nTotal Sale $26.54\n...",
  "meanConfidence": 80.8,
  "wordCount": 55,
  "lineCount": 22,
  "processingMs": 334,
  "imageWidth": 676,
  "imageHeight": 1812,
  "rotation": 0,
  "preprocessing": [],
  "contentType": "image/jpeg",
  "fileBytes": 976574,
  "words": [{"text": "PSI", "confidence": 89.3, "left": 239, "top": 194, "width": 65, "height": 46,
             "block": 1, "paragraph": 1, "line": 1}],
  "hocr": null,
  "tsv": null,
  "errorType": null,
  "error": null
}
```

- `method` is `ocr` when Tesseract read the image or page, and `text-layer` when the PDF page's own text was used
  (then `meanConfidence`, `language`, `imageWidth` and `imageHeight` are null, `words`, `hocr` and `tsv` are not
  given, `processingMs` is the time taken to read the text layer, and the page is charged as a Text page). It is null
  on failed files.
- `page` and `pageCount` are the page number (from 1) and the file's page count for PDFs and multi-page TIFFs, null
  for a single image.
- `meanConfidence` is Tesseract's own 0-100 score averaged over the words. Below 60 usually means a poor read.
- `rotation` is how far the page was turned before reading (90, 180, 270, or a few degrees of straightening).
  Word boxes are in pixels of the page as read, after that turn and after shrinking a page over 5,000 px;
  `imageWidth` and `imageHeight` give that frame.
- `preprocessing` lists what was done: `inverted`, `contrast`, `deskewed`, `upscaled`, `rotated`, `smoothed`.
- Failed files have `ok: false`, `charged: false`, an `errorType` (`dns`, `connect`, `timeout`, `tls`, `http`,
  `blocked_address`, `too_large`, `unreadable`, `not_found`, `invalid_url`, `download`, `ocr_failed`,
  `cost_limit`, `other`) and the `error` in words. When the maximum cost per run is reached, every file not read
  gets a free `cost_limit` row.
- Reading a whole key-value store skips its JSON and text records (no row); name keys to read only those.

### Pricing

Two events, charged per row saved:

| Event | Price | When |
| --- | --- | --- |
| Image | $2.50 per 1,000 ($0.0025) | an image, or a PDF or TIFF page, read by OCR |
| Text page | $0.50 per 1,000 ($0.0005) | a PDF page whose own text was used (`method` is `text-layer`) |

A page read by OCR with no text found still counts, because it was read; anything that could not be read is free.
Set a maximum cost per run in Apify and the actor stops there (a Text page counts a fifth of an image against it).

**How a PDF page is chosen** (PDF text layer "Automatic"): only text a reader of the page can see is taken: text
outside the visible page (crop box), white text on a white background and invisible text not over a picture are left
out. The page's text is used when that leaves at least 50 non-blank characters, at most 5% of them broken (unmapped
glyphs, control characters) and at least half letters or digits (dot leaders, form lines and rules count once).
Otherwise the page is rendered and read by OCR, at the Image price. So these are read as images:

- a page that is mostly a picture (a scan, a screenshot, a slide built around a picture) with only a line or two of
  text of its own (under 300 characters), such as a court filing header, a DocuSign envelope id or a "Confidential"
  footer stamped on a scan: the page body is in the picture. A scan whose picture is covered by an invisible OCR text
  layer is the exception: that layer is used (with the stamp), as a text page. A page with more text than that over
  a big picture (a letter on a letterhead image, a brochure page with a large photo, a dark-theme slide) is a text
  page, and text inside its picture is not read: choose Always OCR for that;
- a PDF with unreadable fonts, and a page of drawings;
- text in the wrong code page: letters that come out as Latin when every language you chose is written in another
  script (Russian saved as Windows-1252, Hindi in a legacy Kruti Dev font), or mostly accented Latin-1 letters.

A page whose text layer holds more than 500,000 characters (far beyond any real page) gets a free `too_large` row;
the other pages of the file are read. Words with boxes, hOCR, TSV and "Only these characters" are OCR output: with any
of them on, every page is read by OCR.

### Tips

- **PDFs that already contain text** (exported from Word, invoices from billing systems) are read from the PDF
  itself at $0.50 per 1,000 pages; scanned pages in the same file are read by OCR, page by page. Text comes out in
  the order the PDF stores it, so multi-column pages and tables may need your own tidying.
- **Set "PDF text layer" to Always OCR** when the PDF's own text cannot be trusted: a scan carrying an old, poor OCR
  layer (that text is passed on as it is, errors included: "Tbe qu1ck brovvn f0x"), text in a wrong code page that
  the checks above miss (for example with English chosen alongside), or a page whose stamp the rules above take for
  its text. Every page is then rendered and read by Tesseract, at the Image price.
- **Receipts and invoices:** Layout "Single column" keeps each price on its item's line.
- **Numbers only:** "Only these characters" `0123456789.,-` for meters, price tags and codes.
- **Mixed languages:** pick all of them, for example English + Spanish; each extra language makes reading slower.
- **Screenshots of apps:** white text on coloured buttons and bars is often missed; the rest of the screen reads well.
- **Speed:** one Tesseract process runs per CPU core, and Apify gives one core per 4 GB of memory. More memory reads
  faster at the same cost per image.

### Other languages

- **Português:** OCR de imagens para texto com Tesseract: extraia texto de imagens, capturas de tela, recibos, notas
  fiscais e PDFs digitalizados, em português e mais 43 idiomas. US$ 2,50 por 1.000 imagens (US$ 0,50 por 1.000 páginas de PDF que já têm texto); arquivos com erro são
  gratuitos.
- **Español:** OCR de imagen a texto con Tesseract: extrae el texto de imágenes, capturas de pantalla, tickets,
  facturas y PDF escaneados, en español y 43 idiomas más. 2,50 USD por 1.000 imágenes (0,50 USD por 1.000 páginas de PDF que ya tienen texto); los archivos con error son
  gratis.
- **Français :** OCR d'image en texte avec Tesseract : extrayez le texte d'images, de captures d'écran, de tickets,
  de factures et de PDF scannés, en français et 43 autres langues. 2,50 USD pour 1 000 images (0,50 USD pour 1 000
  pages de PDF qui contiennent déjà du texte) ; les fichiers en erreur sont gratuits.
- **Deutsch:** Texterkennung (OCR) mit Tesseract: Text aus Bildern, Screenshots, Kassenbons, Rechnungen und gescannten
  PDFs extrahieren, auf Deutsch und in 43 weiteren Sprachen. 2,50 USD pro 1.000 Bilder (0,50 USD pro 1.000 PDF-Seiten, die schon Text enthalten); fehlerhafte Dateien sind
  kostenlos.

### Limits and privacy

- Printed text only; no handwriting, no table structure (use the word boxes to rebuild columns).
- Only public `http(s)` addresses are fetched: private and internal addresses are refused, including after redirects.
- Images over the pixel limit are refused from their header, before they are decoded, and PDF pages holding an
  embedded image over the limit are refused before they are rendered.
- The images are read inside the run and not stored; the text is in your dataset.

# Changelog

This Actor's version history is a separate document: https://apify.com/siteacs/image-ocr/changelog.md

# Actor input Schema

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

Links to the images or PDFs to read, one per line: PNG, JPEG, WebP, GIF, BMP, TIFF (every page), HEIC/HEIF from phones, AVIF, or PDF. Each must be the file itself, not a web page that shows it. Duplicates are read once.

## `keyValueStoreId` (type: `string`):

Read images and PDFs saved in an Apify key-value store (yours, or one from another actor's run). With no keys below, every record is read except JSON and text records.

## `keyValueStoreKeys` (type: `array`):

Only these records of the key-value store. Leave empty to read them all.

## `keyValueStorePrefix` (type: `string`):

Only the records whose key starts with this, for example "receipt-".

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

Read the image URLs found in a field of an Apify dataset, for example the output of a scraper run.

## `datasetField` (type: `string`):

The field that holds the image URL. Use dots for nested fields ("images.url"); a field with a list of URLs, or a list of objects with a "url", gives one file per URL.

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

The languages printed in the images. Pick every language that appears (up to 5); each extra one makes reading slower. Chinese, Japanese and Korean text comes out without spaces between characters.

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

How Tesseract splits the page. Automatic suits pages, scans and screenshots. For receipts, choose Single column: Automatic reads a column of prices after the item names instead of next to them.

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

When a page reads badly, Tesseract's orientation check runs, and a page turned 90, 180 or 270 degrees is turned back and read again. Pages that read well cost nothing extra.

## `deskew` (type: `boolean`):

Turns pages tilted by up to 15 degrees (a crooked scan or photo) so the lines run straight before reading.

## `upscale` (type: `string`):

Tesseract reads letters best at 20-30 pixels high. Automatic doubles images whose longer side is at most 1,600 px (screenshots, thumbnails), which fixes most misread small text.

## `enhanceContrast` (type: `boolean`):

Stretch the gray levels so the darkest 1% becomes black and the lightest 1% white, for faded scans. Light text on a dark background is inverted in any case.

## `retryPoorPages` (type: `boolean`):

When a page reads nothing, or reads with a mean confidence under 60, it is read again from a smoothed copy (grain and JPEG noise on faint text) and the better result is kept.

## `threshold` (type: `string`):

How Tesseract separates text from background. Otsu was the best on every kind of image in our tests; the others can help with uneven lighting.

## `characterWhitelist` (type: `string`):

Limit the output to these characters, for example 0123456789.,- for meters and price tags. Leave empty for all.

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

Add every word with its confidence (0-100), its box (left, top, width, height in pixels of the image, after any rotation) and its block, paragraph and line number.

## `includeHocr` (type: `boolean`):

Add Tesseract's hOCR (HTML with word boxes) for searchable PDFs and layout tools. Its coordinates are those of the image as read (after enlarging and rotation).

## `includeTsv` (type: `boolean`):

Add Tesseract's TSV table (one row per page, block, paragraph, line and word, with boxes and confidence); coordinates as for hOCR.

## `maxImages` (type: `integer`):

Stop after this many files (0 = no limit).

## `maxPdfPages` (type: `integer`):

Read at most this many pages of each PDF or multi-page TIFF, from the first. Each page read is one charged event; pages past the limit are not read, and the run's status says how many.

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

Resolution PDF pages are rendered at before reading. 200 reads normal print well; use 300 for small print.

## `pdfTextLayer` (type: `string`):

PDF pages that already hold real text (exported from Word, invoices from billing systems) are taken from the PDF itself (the text the page shows), with no OCR, and charged as a cheaper "Text page". Scanned pages, pages that are mostly a picture (even with a stamp or header as text) and text in a wrong code page are read by OCR. Choose Always OCR when the PDF's own text cannot be trusted, for example an old, poor OCR layer on a scan. Words with boxes, hOCR, TSV and "Only these characters" are OCR output: with any of them on, every page is read by OCR.

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

Files over this size are skipped, free.

## `maxMegapixels` (type: `integer`):

Images over this many pixels are skipped, free; so is a PDF page holding an embedded image this large. The size is read from the file header before the image is decoded. Pages larger than 5,000 pixels on their longer side are shrunk to 5,000 before reading (text stays readable; reading is faster). With little memory (under 1 GB) the run lowers this limit to what its memory holds.

## Actor input object example

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"
  ],
  "datasetField": "imageUrl",
  "languages": [
    "eng"
  ],
  "pageSegmentationMode": "auto",
  "autoRotate": true,
  "deskew": true,
  "upscale": "auto",
  "enhanceContrast": false,
  "retryPoorPages": true,
  "threshold": "otsu",
  "includeWords": false,
  "includeHocr": false,
  "includeTsv": false,
  "maxImages": 0,
  "maxPdfPages": 20,
  "pdfDpi": 200,
  "pdfTextLayer": "auto",
  "maxFileMb": 50,
  "maxMegapixels": 60
}
```

# Actor output Schema

## `text` (type: `string`):

One row per image or PDF page: the source, page number, text, mean confidence and word count.

## `details` (type: `string`):

Size, rotation, preprocessing, timing, and the error of each file that could not be read.

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

Counts of files, pages read and charged, and errors by type.

# 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://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"
    ],
    "languages": [
        "eng"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("siteacs/image-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 = {
    "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"],
    "languages": ["eng"],
}

# Run the Actor and wait for it to finish
run = client.actor("siteacs/image-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 '{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/f/f1/Arco_3076_receipt_%282003-09-16%29.jpg"
  ],
  "languages": [
    "eng"
  ]
}' |
apify call siteacs/image-ocr --silent --output-dataset

```

## MCP server setup

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