# OCR: Scanned PDF & Image to Text (Word Boxes, Searchable PDF) (`open-data-tools/ocr-pdf-image-to-text`) Actor

OCR scanned PDFs, photos and images to text with Tesseract: per-page text, word boxes with confidence, optional searchable PDF. 28 languages, multi-page PDF and TIFF, file links or another Actor's dataset. Runs on Apify, no outside OCR API. $0.002 per page, no start fee.

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

## Pricing

$2.00 / 1,000 page read (ocr)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

## OCR: Scanned PDF & Image to Text (Word Boxes, Searchable PDF)

Turn scanned PDFs, photos of documents and image files into text. Give it file links or the results of another Actor, and get back one row per page with the page text, a confidence score, and every word with its position on the page. Optionally get a **searchable PDF** for each file.

OCR runs on Apify's own servers with **Tesseract 5**, the open-source OCR engine. Your documents are not sent to any outside OCR or AI service.

### Price

- **$0.002 per page** that returned text ($2 per 1,000 pages)
- **No start fee.** Blank pages, failed pages, failed files and refused links cost nothing.
- The searchable PDF, word boxes and every resolution cost the same.
- Users on the free Apify plan can read up to 50 pages per run.
- Your maximum charge per run is respected: the Actor stops before it would go over.

### What you get for each page

- **text**: the text of the page, with line breaks and blank lines between paragraphs
- **meanConfidence**: average word confidence from 0 to 100, and **lowConfidence** = true when it is under 60 (check those pages)
- **words**: every word as `{text, conf, x, y, w, h, block, par, line}`; boxes are in pixels of the page image (**width** x **height** at **dpi**)
- **wordCount**, **page**, **pageCount**
- **textUrl**: a plain-text file with all pages of the file
- **pdfUrl**: the searchable PDF of the file (when *Make a searchable PDF* is on)
- **status**: `ok`, `blank` (no text found, not charged), `failed` or `skipped`, with the reason in **error**

Example row from a 1970s scanned government report (shortened):

```json
{
  "fileIndex": 1,
  "url": "https://example.com/scans/nbs-report-10653.pdf",
  "page": 7,
  "pageCount": 26,
  "status": "ok",
  "text": "EFFECTS OF DATA AGGREGATION IN MODELLING\n\nThree of the most common problems related to aggregation of data\nsources are ...",
  "wordCount": 249,
  "meanConfidence": 95.1,
  "lowConfidence": false,
  "words": [
    { "text": "EFFECTS", "conf": 96.7, "x": 397, "y": 197, "w": 127, "h": 22, "block": 1, "par": 1, "line": 1 },
    { "text": "OF", "conf": 97, "x": 546, "y": 197, "w": 35, "h": 22, "block": 1, "par": 1, "line": 1 }
  ],
  "dpi": 200,
  "width": 1673,
  "height": 2292,
  "languages": "eng",
  "textUrl": "https://api.apify.com/v2/key-value-stores/.../records/001-nbs-report-10653.txt?signature=...",
  "pdfUrl": "https://api.apify.com/v2/key-value-stores/.../records/001-nbs-report-10653.pdf?signature=..."
}
```

The file links are signed, so they open without an Apify token.

### Input

| Field | What it does |
|---|---|
| PDF or image links | One direct link per line. Scanned or photographed PDFs of any length, PNG, JPEG, TIFF (multi-page too), WEBP, BMP, GIF. Dropbox share links are turned into downloads. |
| Dataset from another Actor | OCR the file links in another Actor's results. The link field is detected (`fileUrl`, `pdfUrl`, `documentUrl`, `imageUrl`, `image`, `images`, `downloadUrl`, `attachmentUrl`, `url`, `link`; lists of links too), or name it in *Link field*. In an integration use `{{resource.defaultDatasetId}}`. |
| Languages | One or more of 28: English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Swedish, Danish, Norwegian, Finnish, Turkish, Russian, Ukrainian, Greek, Romanian, Hungarian, Chinese (simplified and traditional), Japanese, Korean, Arabic, Hebrew, Hindi, Vietnamese, Indonesian. |
| Page layout | Automatic (books, letters, columns), automatic with rotated-page detection, single column, single block (receipts, labels), or sparse text (forms, screenshots). |
| Pages | Which pages to read in each PDF or TIFF, for example `1-5, 9, 12-`. Empty means all. |
| Resolution for PDFs | 200 DPI by default. In our tests 200 read normal print exactly as well as 300 and twice as fast. Use 300 for small print and footnotes, 400 for tiny text. Same price. |
| Make a searchable PDF | One PDF per file: the page image (grayscale) with an invisible text layer you can search, select and copy. |
| Word boxes and confidence | On by default. Turn off for smaller results when you only need text. |
| Maximum pages per file | 1,000 by default. |

### What it is good for

- Making old scanned reports, books, letters and archives searchable
- Pulling text out of scanned invoices, contracts and forms before you parse them
- Feeding scanned documents to an LLM or a search index (RAG)
- Checking OCR quality page by page with the confidence score, and finding words on the page with their boxes
- Running after a scraper that collects PDF or image links, through an Actor-to-Actor integration

### What it does not do

- It does not read handwriting well. Tesseract is built for printed text.
- It does not open web pages, social media, Google or Amazon links. Give a direct link to the file. Those links are refused and not charged.
- Password-protected PDFs fail (not charged).
- It does not keep the original colour in the searchable PDF: pages are stored in grayscale to keep the file small.
- PDFs that already have real text (not scans) are still read as images. That works, but a plain PDF text extractor is cheaper for them.

### Tips

- If a page comes back with low confidence, try 300 DPI, or set the language. Choosing several languages makes OCR a little slower and sometimes less accurate, so pick only the ones in your documents.
- For receipts and labels, try *Single block of text*. For forms and screenshots with scattered text, try *Sparse text*.
- For pages scanned sideways or upside down, choose *Automatic + detect rotated pages*.

### Limits

- Files up to 500 MB. Very large page images are scaled down to 40 megapixels.
- Each page has a 10-minute OCR limit.

# Actor input Schema

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

One direct file link per line: scanned or photographed PDFs (any number of pages), PNG, JPEG, TIFF (multi-page too), WEBP, BMP or GIF. Dropbox share links work. Web pages and social media, Google and Amazon links are refused and not charged.

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

Optional. OCR the file links in another Actor's results, for example a document, invoice or image scraper. In an Actor-to-Actor integration set it to {{resource.defaultDatasetId}}.

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

Field in the dataset that holds the file link(s). Leave empty to detect it (fileUrl, pdfUrl, documentUrl, imageUrl, image, images, downloadUrl, attachmentUrl, url, link). Dots reach nested fields (files.0.url); separate several with commas.

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

Languages in the documents. Pick one or more (each extra language makes OCR a little slower). English by default.

## `pageLayout` (type: `string`):

How the text is laid out on the page. Automatic works for books, letters and multi-column pages.

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

Which pages to read in each PDF or multi-page TIFF, for example 1-5, 9, 12-. Leave empty for all pages.

## `dpi` (type: `integer`):

PDF pages are turned into images at this resolution before OCR. 200 reads normal print (10 pt and up) as well as 300 in our tests and is twice as fast; use 300 for small print or footnotes, 400 for tiny text. Same price. Images are read at their own size.

## `searchablePdf` (type: `boolean`):

Also create one searchable PDF per file (grayscale page image with an invisible text layer you can search and copy). Same price.

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

Add every word with its confidence (0-100) and box (x, y, w, h in pixels of the page image) to each page row.

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

Longer files are read up to this many pages. You pay only for pages that return text.

## Actor input object example

```json
{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/kcQByrm44yeiIuKZp/records/scanned-book-24-pages.pdf"
  ],
  "languages": [
    "eng"
  ],
  "pageLayout": "3",
  "dpi": 200,
  "searchablePdf": false,
  "includeWords": true,
  "maxPagesPerFile": 1000
}
```

# Actor output Schema

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

One row per page: text, confidence, word boxes and links to the text and searchable PDF files.

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

Plain-text and searchable PDF files in the 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 = {
    "urls": [
        "https://api.apify.com/v2/key-value-stores/kcQByrm44yeiIuKZp/records/scanned-book-24-pages.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("open-data-tools/ocr-pdf-image-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 = { "urls": ["https://api.apify.com/v2/key-value-stores/kcQByrm44yeiIuKZp/records/scanned-book-24-pages.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("open-data-tools/ocr-pdf-image-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 '{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/kcQByrm44yeiIuKZp/records/scanned-book-24-pages.pdf"
  ]
}' |
apify call open-data-tools/ocr-pdf-image-to-text --silent --output-dataset

```

## MCP server setup

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