# PDF to Text & OCR – Scanned PDF, Image & Screenshot to Text (`mvisiondigital/pdf-image-ocr`) Actor

PDF to text and image to text in one Actor. Reads a PDF's own text when it has one and runs OCR only on scanned pages, images and screenshots, so you pay OCR prices only where needed. Text per page plus one text file per document.

- **URL**: https://apify.com/mvisiondigital/pdf-image-ocr.md
- **Developed by:** [Mohit Sawhney](https://apify.com/mvisiondigital) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.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

### What it does

PDF & Image OCR gets the text out of PDFs, scanned documents and photos of text.

- **Digital PDFs** (made by Word, Google Docs, invoices from software): the text is read directly from the file. Exact, fast and cheap.
- **Scanned PDFs and images** (scans, phone photos, screenshots, faxes): the text is read with OCR.
- **Mixed PDFs**: each page is handled the right way on its own, so you only pay OCR prices for pages that need it.

You get the text of every page, plus one text file with the whole document.

Common uses: making scanned archives searchable, feeding documents to an AI model or a RAG pipeline, pulling text from invoices, receipts, forms and letters, and indexing PDFs on a website.

### How much it costs

You pay **per page**:

- **Text-layer page**: a PDF page that already contains text.
- **OCR page**: a scanned page or an image.

See the Pricing tab for current prices. Files that fail are not charged. Set "Most pages per file" to cap long documents.

### Input

| Field | What it means |
|---|---|
| File links | Direct links to PDFs or images (PNG, JPG, WebP, TIFF, BMP, GIF). Multi-page TIFFs work too. |
| When to use OCR | **Auto** (recommended) uses the PDF's own text where it has one. **Always** runs OCR on every page. |
| Include line positions | Adds each OCR'd line with its confidence and bounding box, for layout or highlighting. |
| Most pages per file | Safety cap. Default 200. |
| Scan resolution for OCR | 2 suits most documents. Use 3 for very small print. |

Example:

```json
{
    "fileUrls": ["https://example.com/scanned-contract.pdf"],
    "ocrMode": "auto"
}
```

### Output

One row per page:

```json
{
    "fileUrl": "https://example.com/scanned-contract.pdf",
    "page": 2,
    "method": "ocr",
    "text": "This Agreement is made on ...",
    "characters": 2381,
    "confidence": 0.962,
    "fileTextUrl": "https://api.apify.com/v2/key-value-stores/.../records/file-001.txt",
    "error": null
}
```

`method` is `text-layer` or `ocr`. `confidence` is the average OCR confidence (0 to 1) and is empty for text-layer pages. `fileTextUrl` links to the whole document as one text file.

### Use it as an API

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("mvisiondigital/pdf-image-ocr").call(run_input={
    "fileUrls": ["https://example.com/scanned-contract.pdf"],
})
for page in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(page["page"], page["text"][:80])
```

### Good to know

- OCR works best on English and other Latin-script text, and on Chinese.
- Handwriting is recognised poorly; printed text works best.
- Password-protected PDFs are not supported.
- Files up to 500 MB.

# Actor input Schema

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

Direct links to PDFs or images (PNG, JPG, WebP, TIFF, BMP, GIF).

## `ocrMode` (type: `string`):

Auto reads the PDF's own text where it has one (cheaper and exact) and runs OCR only on scanned pages. Always runs OCR on every page.

## `includeLines` (type: `boolean`):

Add each OCR'd line with its confidence and bounding box.

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

Pages after this are skipped and not charged.

## `renderScale` (type: `number`):

How sharply PDF pages are rendered before OCR. 2 (about 144 DPI) suits most documents; use 3 for small print.

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/RapidAI/RapidOCR/main/python/tests/test_files/ch_en_num.jpg"
  ],
  "ocrMode": "auto",
  "includeLines": false,
  "maxPagesPerFile": 200,
  "renderScale": 2
}
```

# Actor output Schema

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

One row per page with its text, plus a link to the whole document as a text file.

# 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": [
        "https://raw.githubusercontent.com/RapidAI/RapidOCR/main/python/tests/test_files/ch_en_num.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mvisiondigital/pdf-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 = { "fileUrls": ["https://raw.githubusercontent.com/RapidAI/RapidOCR/main/python/tests/test_files/ch_en_num.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("mvisiondigital/pdf-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 '{
  "fileUrls": [
    "https://raw.githubusercontent.com/RapidAI/RapidOCR/main/python/tests/test_files/ch_en_num.jpg"
  ]
}' |
apify call mvisiondigital/pdf-image-ocr --silent --output-dataset

```

## MCP server setup

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