# OCR: Image & PDF to Text — Scanned PDF, Screenshot, Photo OCR (`steadyscrape/ocr-image-pdf-to-text`) Actor

OCR API for images and PDFs: extract text from scanned PDFs, screenshots, photos, receipts and invoices, with line boxes, confidence and detected language. Reads a PDF's own text when it has one. 40+ languages, rotated pages fixed. Export to JSON, CSV, TXT or Markdown, or via API.

- **URL**: https://apify.com/steadyscrape/ocr-image-pdf-to-text.md
- **Developed by:** [Steady Scrape](https://apify.com/steadyscrape) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 page read by ocrs

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 & PDF to Text — extract text from scanned PDFs, screenshots and photos

An **OCR API for images and PDFs**: give it links to pictures or PDFs and get, for **every page**, the full text, each
line with its **bounding box and confidence**, the text grouped in blocks in **reading order**, the **detected
language and script**, and the page's size. Image to text and PDF to text in one Actor: scanned PDFs, screenshots,
phone photos of documents, receipts, invoices, forms, book scans, multi-page TIFFs.

**The OCR runs inside the Actor.** An open model (PaddleOCR's PP-OCR, run with ONNX Runtime) reads your files on the
Actor's own CPU: no Google Vision, no cloud OCR API, no LLM, nothing your documents are sent to, and no key to bring.

**A PDF that already has its text is not OCR'd.** A page made by a program (Word, a browser, an invoicing system)
carries its own text: it is read exactly, in milliseconds, and billed at a fifth of an OCR page. Only scanned pages go
through OCR. You can force OCR, or forbid it.

### Pricing

| event | price | when |
|---|---|---|
| `page` | **US$0.0025** (US$2.50 per 1,000 pages) | a page or picture read by OCR |
| `text-page` | **US$0.0005** (US$0.50 per 1,000 pages) | a PDF page read from its own text, no OCR |

A link that does not answer, a web page, a password-protected PDF, a blank page, a file too large: each leaves **one
row that says why, and costs nothing**.

### What it reads

- **Images**: PNG, JPG, WebP, TIFF (every page of a multi-page scan), BMP, GIF (first frame), HEIC from iPhones.
- **PDFs**: every page, or the pages you ask for (`1-3, 5, 10-`), up to 100 per file by default.
- **Share links**: Google Drive files and Google Docs/Slides (exported to PDF), Dropbox links. They must be shared with
  "Anyone with the link".
- **Another Actor's output**: pick a dataset (screenshots, product images, scraped PDFs) and name the field that holds
  the links, or let the Actor find the picture and PDF fields itself. Signed links of Apify key-value records work too.
- **Sideways and upside-down pages** are found and read the right way up (`autoRotate`), and phone photos are turned by
  their EXIF orientation.

Pages of Instagram, TikTok, Facebook, X, YouTube and other social or video platforms are refused before anything is
downloaded: this Actor reads your own files, it does not download from platforms.

### Use cases

- **Scanned PDFs to searchable text**: archives, contracts, letters, old reports; a `.txt` per file with its pages in
  order, ready for search or an index.
- **Receipts and invoices**: the text with each line's position, so totals and dates can be picked out by where they
  are; items stay on one line with their price.
- **Screenshots**: read the text of screenshots another Actor took (a website screenshot API, a social media scraper).
- **AI and RAG pipelines**: clean text per page with confidence, language and a stable JSON shape, from documents an
  LLM cannot read as files.
- **Forms and book scans**: blocks in reading order, two-column pages read column by column, headings in the Markdown.

### Input

| field | what it does |
|---|---|
| `files` | Links to images and PDFs, up to 300 MB each and 1,000 per run. |
| `datasetId` | A dataset of another run; every image or PDF link in it is read. |
| `datasetFields` | The dataset fields that hold the links (`images.url` takes the url of every element of `images`). Empty: the Actor picks picture, screenshot, scan, PDF, document, receipt and invoice fields, and leaves thumbnails, avatars and logos out. |
| `script` | The alphabet: `latin` (default: English and other Latin-alphabet languages, plus Chinese), `japanese`, `korean`, `cyrillic`, `arabic`, `devanagari`, `thai`, `greek`, `tamil`, `telugu`. |
| `pdfMode` | `auto` (default: a PDF's own text when it has one, OCR for scanned pages), `ocr` (always OCR), `text-layer-only` (never OCR). |
| `pages` | Which pages of each PDF or TIFF, like `1-3, 5, 10-`. Empty: every page. |
| `maxPagesPerFile` | Pages past this are named in one free row (default 100, up to 2,000). |
| `autoRotate` | Find text turned 90, 180 or 270 degrees and read it upright (default on). |
| `outputFiles` | Also write, per input file, a `txt` (pages apart by a form feed), an `md` (Markdown with page headings) and/or a `json` (pages → blocks → lines with boxes). Each comes with a link that opens for anyone. |

```json
{
    "files": [
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ],
    "outputFiles": ["txt"]
}
```

### Output

One row per image or PDF page. This is the real row of the first file of the example above (lines shortened to two):

```json
{
    "status": "ok",
    "fileIndex": 1,
    "sourceUrl": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
    "fileName": "eurotext.tif",
    "fileType": "tiff",
    "pageNumber": 1,
    "pageCount": 1,
    "method": "ocr",
    "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.\nDer ,schnelle\" braune Fuchs springt\nüber den faulen Hund. Le renard brun\n«rapide» saute par-dessus le chien\nparesseux. La volpe marrone rapida\nsalta sopra il cane pigro. El zorro\nmarrón rápido salta sobre el perro\nperezoso. A raposa marrom rápida\nsalta sobre o cão preguiçoso.",
    "blocks": [{ "text": "The (quick) [brown] {fox} jumps!\nOver the $43,456.78 …", "box": { "x": 92, "y": 53, "width": 833, "height": 613 }, "lineCount": 12 }],
    "lines": [
        { "text": "The (quick) [brown] {fox} jumps!", "confidence": 0.9799, "box": { "x": 98, "y": 53, "width": 737, "height": 63 }, "polygon": [[99, 53], [835, 63], [834, 116], [98, 106]], "block": 0 },
        { "text": "Over the $43,456.78 <lazy> #90 dog", "confidence": 0.9796, "box": { "x": 98, "y": 102, "width": 795, "height": 65 }, "polygon": [[99, 102], [893, 114], [892, 167], [98, 155]], "block": 0 }
    ],
    "language": "es",
    "script": "Latin",
    "confidence": 0.984,
    "rotation": 0,
    "width": 1024,
    "height": 800,
    "dpi": null,
    "lineCount": 12,
    "wordCount": 69,
    "charCount": 347,
    "textFileUrl": "https://api.apify.com/v2/key-value-stores/…/records/001-eurotext.txt?signature=…",
    "billedEvent": "page"
}
```

The PDF of the example has its own text, so its row says `"method": "text-layer"`, `"confidence": null` (the text is
exact) and `"billedEvent": "text-page"`.

#### Fields

| field | meaning |
|---|---|
| `status` | `ok`, or why there is no text: `no_text`, `invalid`, `unreachable`, `not_supported`, `too_large`, `protected`, `refused`, `skipped`, `failed`. Only `ok` rows are billed. |
| `reason` | For every row that is not `ok`: what happened and what to do about it. |
| `fileIndex`, `pageNumber`, `pageCount` | The file's place in the run, the page, and how many pages the file has. |
| `sourceUrl`, `fileName`, `fileType` | The link as you gave it, the file's name, and its type (`pdf`, `png`, `jpg`, `tiff`…). |
| `method` | `ocr`, or `text-layer` for a PDF page read from its own text. |
| `text` | The page's text in reading order: lines on their own lines, blocks apart by a blank line. |
| `blocks` | Paragraphs, columns and table rows, each with its text, its box and its number of lines. |
| `lines` | Every line with its text, `confidence` (0–1, `null` for a PDF's own text), its `box` (x, y, width, height) and its `polygon` (four corners, for slanted text), in the pixels of the page as you sent it, and the `block` it belongs to. |
| `language`, `script` | ISO code of the language (`en`, `de`, `zh`…) and the Unicode script (`Latin`, `Han`, `Cyrillic`…). |
| `confidence` | The mean confidence of the page's lines. |
| `rotation` | How far the text was turned (0, 90, 180, 270), `null` when `autoRotate` is off. |
| `width`, `height`, `dpi` | The page's size in pixels; for a PDF, rendered at `dpi` (200). |
| `wordCount`, `charCount`, `lineCount` | Counts of the page's text (Chinese and Japanese words included). |
| `textFileUrl`, `markdownFileUrl`, `jsonFileUrl` | The file's outputs, when asked for: links that open for anyone. |
| `datasetItemIndex` | For links taken from a dataset, the item they came from. |
| `billedEvent`, `processingSeconds`, `processedAt` | What the page was billed as, how long it took, when. |

### Languages

One run reads one script, chosen with `script`:

- **`latin`** (default, the fastest): English, Spanish, French, German, Portuguese, Italian, Dutch, the Nordic
  languages, Indonesian, Malay, Swahili and other Latin-alphabet languages, **plus Chinese** (simplified and
  traditional), mixed on one page. Polish, Czech, Romanian and Vietnamese are read, but some of their accents are lost.
- **`japanese`** (with Chinese and English), **`korean`**, **`cyrillic`** (Russian, Ukrainian, Bulgarian, Serbian,
  Kazakh…), **`arabic`** (Arabic, Persian, Urdu), **`devanagari`** (Hindi, Marathi, Nepali), **`thai`**, **`greek`**,
  **`tamil`**, **`telugu`**.

The language of each page is detected from its text and given in its row. On a page of a few words (a receipt, a
one-line title) it is left `null` rather than guessed.

### Speed and memory

The Actor runs with **2 GB** of memory by default. Measured on Apify at 2 GB: a dense A4 page of a research paper was
OCR'd in 2.1–2.3 s, a scanned page of a dozen lines in half a second, and a PDF page with its own text in
milliseconds. From 6 GB the engine runs on two cores; under 2 GB a large photo or a big PDF page can run out of memory.

If your spending limit pays only for part of the run, the Actor stops at the limit and says which pages it did not
read; when only `text-page` is left, it still reads PDF pages that have their own text. A run moved by Apify to another
server goes on where it was: no page is read or billed twice.

### Limits

- The model is made for printed text: do not count on it for handwriting.
- 300 MB per file, 120 million pixels per image, 1,000 files per run, 2,000 pages per file.
- Password-protected PDFs, Word/Excel files and archives are not opened: export to PDF, or remove the password.
- A PDF whose own text is garbled (broken fonts) is usually caught and OCR'd instead; if one slips through, use
  `pdfMode: ocr`.
- Tables come out as rows of text with their boxes, not as cells.

### Is it legal?

It reads files you give it: your own documents, or files you have the right to process. Do not use it on documents
that contain other people's personal data unless you have a lawful basis to process them (GDPR, CCPA and similar).

This Actor is not affiliated with, endorsed by or connected to PaddlePaddle, RapidAI, Google or Dropbox. It runs the
open PP-OCR models (Apache-2.0) through RapidOCR (Apache-2.0); Google Drive and Dropbox links are only downloaded as
the files they share.

### Related

- [Audio & Video Transcriber](https://apify.com/steadyscrape/audio-video-transcriber): the same idea for speech —
  audio and video files to text, SRT and VTT subtitles, with Whisper running inside the Actor.
- Questions or a file it reads badly? Open an issue on the Actor's Issues tab; it is answered.

# Actor input Schema

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

Links to your own images (PNG, JPG, WebP, TIFF including multi-page scans, BMP, GIF, HEIC) and PDFs, up to 300 MB each. Google Drive and Dropbox share links (shared with anyone with the link), Google Docs links, and signed links of Apify key-value records work as they are. Pages of Instagram, TikTok, Facebook, X, YouTube and other platforms are refused before anything is downloaded, free.

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

Pick the dataset of another run (screenshots, product images, scraped PDFs, invoices) and every image or PDF link in it is read. Only the dataset you pick here can be read.

## `datasetFields` (type: `array`):

The fields of each dataset item that hold the links, as dotted paths (images.url takes the url of every element of images). Leave empty to take every link in a field named like image, screenshot, scan, pdf, document, file, receipt or invoice, or ending in .pdf, .png, .jpg and the like (thumbnails, avatars and logos are left out).

## `script` (type: `string`):

The alphabet of the text. One run reads one script: the default reads English, Spanish, French, German, Portuguese, Italian, Dutch, the Nordic languages, Indonesian and other Latin-alphabet languages, plus Chinese (simplified and traditional), all mixed on one page. Polish, Czech, Romanian and Vietnamese are read with some of their accents lost. The language of each page is detected and given in its row.

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

A PDF page made by a program (Word, a browser, an invoicing system) carries its own text: <b>auto</b> reads that text exactly and cheaply (the <code>text-page</code> event) and OCRs only scanned pages. <b>Always OCR</b> reads every page from its picture, for PDFs whose own text is wrong. <b>Own text only</b> never OCRs: scanned pages come back as free rows.

## `pages` (type: `string`):

Which pages of each PDF or multi-page TIFF to read, like <code>1-3, 5, 10-</code> (10- is page 10 to the end). Empty reads every page, up to the limit below.

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

Pages past this are left out and named in a free row, so one long PDF cannot spend the whole run.

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

Find pages and photos whose text is turned 90, 180 or 270 degrees (sideways scans, upside-down photos) and read them the right way up. The row gives the rotation found; boxes stay on the picture as you sent it.

## `outputFiles` (type: `array`):

One file per input file in the run's key-value store, every page of it in order, with a link that opens for anyone in every row of that file: <b>txt</b> (pages apart by a form feed), <b>md</b> (Markdown with page headings), <b>json</b> (pages, blocks and lines with their boxes). Rows always carry each page's text, blocks and lines.

## Actor input object example

```json
{
  "files": [
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "script": "latin",
  "pdfMode": "auto",
  "maxPagesPerFile": 100,
  "autoRotate": true,
  "outputFiles": []
}
```

# Actor output Schema

## `pages` (type: `string`):

No description

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

No description

## `summary` (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 = {
    "files": [
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("steadyscrape/ocr-image-pdf-to-text").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 = { "files": [
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("steadyscrape/ocr-image-pdf-to-text").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 '{
  "files": [
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/eurotext.tif",
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call steadyscrape/ocr-image-pdf-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,steadyscrape/ocr-image-pdf-to-text"
        }
    }
}
```

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/B37gFWnZ4P203xett/builds/exjXny6RRva6Bsmmo/openapi.json
