# Image to Text OCR: Scanned PDF, JPG & PNG to Text (`forgeloop/image-pdf-ocr`) Actor

OCR for images and scanned PDFs: get the text out of PNG, JPG, WEBP, TIFF and PDF files. Seven languages included, text-layer PDFs read without OCR. For invoices, receipts, contracts, forms and screenshots, ready for RAG and automation. Pay per page with text.

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

## Pricing

from $4.00 / 1,000 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

## Image to Text OCR: Scanned PDF, JPG & PNG to Text

Get the text out of images and scanned PDFs. Give it a list of links to PNG, JPG, WEBP or TIFF files or PDFs, get back one item per file with the recognized text.

Made for documents that have no text you can copy: scanned invoices, receipts, contracts, letters, forms and screenshots. Feed the result into RAG pipelines, search indexes, spreadsheets or your own automation.

### What it does

- Downloads each file from its URL and detects the type from the file content, not the file name.
- **Images** (PNG, JPG, WEBP, TIFF, GIF, BMP) go straight to OCR.
- **PDFs** are read page by page:
  - Pages that already have a text layer use that text. It is faster and exact.
  - Scanned pages are rendered at the resolution you choose and run through OCR.
  - Turn on **Force OCR** to OCR every page, for example when the text layer is broken.
- Returns a confidence score (0 to 100) so you can flag bad scans for review.
- Plain text or Markdown output. Markdown joins the lines of each paragraph and marks PDF pages with `<!-- page 3 -->`.
- The OCR engine (Tesseract, LSTM models) runs inside the Actor. Your files are not sent to any third-party OCR service.

### Supported languages

English, German, French, Spanish, Italian, Portuguese and Dutch. Select every language that appears in your files. Each extra language makes OCR a little slower.

### Input

| Field | Description | Default |
|---|---|---|
| File URLs | Direct links to images or PDF files | |
| Languages | Languages of the text, one or more | English |
| Output format | `text` or `markdown` | text |
| Max pages per file | Pages beyond this limit are skipped and not charged | 50 |
| Force OCR | OCR every PDF page, even with a text layer | off |
| PDF render resolution (DPI) | 72 to 300. Use 300 for small print | 200 |
| Max file size (MB) | Larger files are skipped with an error | 30 |

### Output

One dataset item per file:

```json
{
  "url": "https://tesseract.projectnaptha.com/img/eng_bw.png",
  "fileType": "png",
  "languages": ["eng"],
  "pageCount": 1,
  "processedPages": 1,
  "ocrPages": 1,
  "confidence": 92,
  "text": "Mild Splendour of the various-vested Night!\nMother of wildly-working visions! hail\n...",
  "characters": 351,
  "truncated": false,
  "error": null
}
```

- `ocrPages`: pages that needed OCR. The rest came from the PDF text layer.
- `confidence`: mean OCR confidence of the OCR pages. `null` when no page needed OCR.
- `truncated`: `true` when the page limit cut the file short.
- `error`: why a file failed, for example an HTML page instead of a file. Failed files have `text: null`.

Export as JSON, CSV or Excel, or read it through the Apify API.

### Pricing

Pay per processed page that produced text. An image counts as one page. Failed files and pages without any text are not charged. You can cap the cost of a run with the maximum charge setting in Apify.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start.

If your PDFs all have a text layer (born digital, not scanned), a plain PDF to text converter is cheaper.

### Performance and memory

- A clean image takes about a second. A dense scanned A4 page takes a few seconds of CPU time.
- 2048 MB memory (the default) is enough for normal documents. More memory also gives the run more CPU, so OCR gets faster.

### Limits

- Handwriting is recognized poorly. The Actor is built for printed text.
- Accuracy depends on the scan: low resolution, blur, skew, stamps, coloured backgrounds and old typewriter copies lower the confidence score.
- Photos with EXIF rotation are read as stored. Rotate them first if the text is sideways.
- Multi-page TIFF files: only the first page is read.
- Tables come back as text lines, not as table cells. Layout is not kept.
- Only public `http` and `https` links. Password protected PDFs are not supported.

### Data source, permitted use and legal

- **Data source:** The files at the URLs you enter. The Actor downloads each file once during the run. Text recognition runs inside the Actor with the open source Tesseract engine.
- **Snapshot:** Results show the source at the time of the run. We do not guarantee that they are complete, current or correct.
- **For business use:** This Actor is offered to businesses only, not to consumers.
- **Permitted use:** Process only content you are allowed to access and use, for example your own websites and documents or public pages you have a legitimate reason to process. Respect the terms of the websites and the rights in the content.
- **Your responsibility:** You choose the URLs and decide what happens with the results. If results contain personal data, you are the controller and need your own legal basis.
- **No circumvention:** The Actor does not log in, solve captchas or bypass paywalls, bot protection or other access restrictions. Do not use it for that.
- **Request volume:** One download per file link. Do not use it to put excessive load on a website.
- **Provider:** forgeloop, Markus Heiss, Austria. [Imprint](https://devhem.github.io/forgeloop-legal/imprint.html), [Privacy Notice](https://devhem.github.io/forgeloop-legal/privacy.html), [Terms of Use](https://devhem.github.io/forgeloop-legal/terms.html).

### Questions and issues

Open an issue on the Actor page. Bugs are fixed quickly.

# Actor input Schema

## `sources` (type: `array`):

Direct links to images (PNG, JPG, WEBP, TIFF, GIF, BMP) or PDF files. One output item per file. Format: a list of objects with a url key, like \[{"url": "https://example.com/scan.png"}]. Plain strings are not accepted.

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

Languages of the text. Pick all languages that appear in your files. Each extra language makes OCR a bit slower.

## `outputFormat` (type: `string`):

Plain text keeps the line breaks as recognized. Markdown joins the lines of each paragraph and adds page markers like  for PDFs.

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

Stop after this many pages of each PDF. Pages beyond the limit are not processed and not charged.

## `forceOcr` (type: `boolean`):

Run OCR on every PDF page, even when the page already has a text layer. Off: the text layer is used where it exists, which is faster and more accurate.

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

Resolution used to render scanned PDF pages before OCR. 200 is a good balance. Use 300 for small print, lower values for speed.

## `maxFileSizeMb` (type: `integer`):

Files larger than this are skipped with an error.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
    }
  ],
  "languages": [
    "eng"
  ],
  "outputFormat": "text",
  "maxPagesPerFile": 50,
  "forceOcr": false,
  "dpi": 200,
  "maxFileSizeMb": 30
}
```

# Actor output Schema

## `results` (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 = {
    "sources": [
        {
            "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forgeloop/image-pdf-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 = { "sources": [{ "url": "https://tesseract.projectnaptha.com/img/eng_bw.png" }] }

# Run the Actor and wait for it to finish
run = client.actor("forgeloop/image-pdf-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 '{
  "sources": [
    {
      "url": "https://tesseract.projectnaptha.com/img/eng_bw.png"
    }
  ]
}' |
apify call forgeloop/image-pdf-ocr --silent --output-dataset

```

## MCP server setup

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