# Scanned PDF OCR: Searchable PDF + Text (`iiclabs/scanned-pdf-ocr-searchable`) Actor

Turn scanned PDFs and images into searchable PDFs: OCR adds an invisible text layer and keeps every page looking the same, so files can be searched, copied and indexed where they are. Also returns the text of each page. 16 languages, PDF/A option.

- **URL**: https://apify.com/iiclabs/scanned-pdf-ocr-searchable.md
- **Developed by:** [IIC Labs](https://apify.com/iiclabs) (community)
- **Categories:** Developer tools, Automation
- **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 pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Scanned PDF OCR: Searchable PDF + Text

**Turn scanned PDFs and images into searchable PDFs.** OCR adds an invisible text layer to every page and keeps the page exactly as it looked, so the file can be searched, copied from and indexed where it is: in your document system, your shared drive or your search index. You also get the text of each page in the dataset.

Most OCR tools give you only the text. This one gives you **the document back, searchable**, the way scanners in law firms, accounting offices and archives are expected to deliver it, plus the text for your search index or AI pipeline.

### What you get

For each file:

- **a searchable PDF** in the run's key-value store, same pages and images, plus a hidden text layer (optionally **PDF/A-2b** for long-term archiving);
- **the text of each page** (on by default), with a flag for pages that already had their own text;
- the number of pages, how many were OCR'd and how many already had text.

Pages that already carry real text (born-digital pages) are kept as they are and charged at a much lower rate, so mixed documents cost less.

### Input

| Field | What it does |
|---|---|
| **Files** | URLs of PDFs or images (JPEG, PNG, TIFF), up to 200 MB each. |
| **Languages** | English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Czech, Swedish, Danish, Norwegian, Finnish, Turkish, Romanian, Hungarian. Pick the ones in your documents. |
| **Pages that already have text** | *Skip* (default) keeps them; *Redo* replaces old OCR text; *Force* OCRs every page again. |
| **Fix page rotation** | Turns sideways and upside-down scans upright. |
| **PDF/A for archiving** | Saves PDF/A-2b. |
| **File size** | Keep images, optimise losslessly (default) or compress more. |
| **Text per page in the dataset** | On by default. |
| **Maximum pages per file** | Longer PDFs are refused and not charged (default 500). |

```json
{
  "files": ["https://example.com/scans/contract-2019.pdf", "https://example.com/scans/receipt.jpg"],
  "languages": ["eng", "deu"],
  "pdfA": true
}
```

### Output

One dataset item per file:

```json
{
  "url": "https://example.com/scans/contract-2019.pdf",
  "status": "ok",
  "kind": "pdf",
  "pages": 12,
  "ocrPages": 11,
  "textLayerPages": 1,
  "languages": ["eng", "deu"],
  "searchablePdf": {
    "key": "001-contract-2019.pdf",
    "url": "https://api.apify.com/v2/key-value-stores/<store-id>/records/001-contract-2019.pdf",
    "bytes": 2483021
  },
  "pageTexts": [
    { "page": 1, "ocr": true, "text": "SERVICE AGREEMENT\n\nThis agreement is made ..." }
  ],
  "error": null
}
```

Files that can't be processed (password-protected or digitally signed PDFs, broken downloads, unsupported formats) are listed with the reason and **not charged**.

### Pricing

Pay per event:

- **OCR page**: each page that goes through OCR.
- **Text page**: each page that already had its own text and was kept (much cheaper).
- A small start fee per run, set by Apify.

The *Maximum cost per run* you set in Apify is respected: files not reached are listed as skipped.

### How it works

The Actor runs [OCRmyPDF](https://ocrmypdf.readthedocs.io/) with the [Tesseract](https://github.com/tesseract-ocr/tesseract) OCR engine, both open source, inside the run. Your files go nowhere else: no third-party OCR service sees them, and no AI service is involved. Output stays in your own Apify storage.

### Good to know

- OCR quality depends on the scan: clean 300 DPI scans give the best results; photos at an angle, handwriting and very small print give weaker text.
- Digitally signed PDFs are refused, because changing them would break the signature.
- Keep the language list short: every extra language slows OCR down.

### FAQ

**Can I use it from my own code?** Yes, call it through the Apify API or the Apify clients, and download each PDF from its `searchablePdf.url` with your Apify token.

**Can I run it on a schedule or on new files?** Yes, with Apify Schedules or integrations (webhooks, Make, Zapier, n8n).

**Support:** support+pdfocr@iiclabs.com. Include the run ID if something looks wrong. If it helped you, a rating on this page helps others find it.

# Actor input Schema

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

URLs of scanned PDFs or images (JPEG, PNG, TIFF), up to 200 MB each.

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

The languages in the documents. Choose only the ones present: each extra language slows OCR down.

## `mode` (type: `string`):

Skip keeps a page's existing text layer (born-digital pages are charged at the lower text-page price). Redo replaces old OCR text but keeps real text. Force OCRs every page again (the page is turned into an image).

## `rotatePages` (type: `boolean`):

Turns sideways or upside-down pages upright (not with Redo).

## `pdfA` (type: `boolean`):

Save PDF/A-2b instead of a regular PDF.

## `optimize` (type: `string`):

Keep images as they are, optimise losslessly (safe), or compress images more.

## `includeText` (type: `boolean`):

Also return each page's text, for search indexes and AI pipelines.

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

Longer PDFs are refused (not charged).

## Actor input object example

```json
{
  "files": [
    "https://iiclabs.com/samples/scanned-sample.pdf"
  ],
  "languages": [
    "eng"
  ],
  "mode": "skip-text",
  "rotatePages": true,
  "pdfA": false,
  "optimize": "1",
  "includeText": true,
  "maxPagesPerFile": 500
}
```

# Actor output Schema

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

One item per file: status, pages, the searchable PDF's link and the text per page.

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

Files done and failed, pages OCR'd and kept.

# 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://iiclabs.com/samples/scanned-sample.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("iiclabs/scanned-pdf-ocr-searchable").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://iiclabs.com/samples/scanned-sample.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("iiclabs/scanned-pdf-ocr-searchable").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://iiclabs.com/samples/scanned-sample.pdf"
  ]
}' |
apify call iiclabs/scanned-pdf-ocr-searchable --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,iiclabs/scanned-pdf-ocr-searchable"
        }
    }
}
```

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/gwFWKP4ayHjJGc9Az/builds/Ok1dwprCSjmhSEIMi/openapi.json
