# Image to Text OCR: Searchable PDFs, Scans & Screenshots (`pikoulas/image-ocr`) Actor

Extract text from images, screenshots and scanned PDFs with OCR, and turn scans into searchable PDFs. From URLs or a scraper's dataset; every page turned upright and read in 51 languages, with confidence and line positions. No API key. $1.50 per 1,000 pages; blanks free.

- **URL**: https://apify.com/pikoulas/image-ocr.md
- **Developed by:** [Spyridon Pikoulas](https://apify.com/pikoulas) (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 $1.50 / 1,000 image or pdf page reads

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

## Image to Text OCR: Searchable PDFs, Scans & Screenshots

Give it images or scanned PDFs, and get the text in them back as clean JSON, and as **searchable PDFs** if you like:

- **Searchable PDFs:** each scan or image made a PDF that looks the same, with the text found laid under it, invisible,
  so it can be searched, selected and copied in any PDF reader, a whole scanned PDF as one file. Free with the text.

- **From a list of URLs or straight from another run's dataset:** point it at a social media, product or listing
  scraper's results and it reads the text in their images.

- **Screenshots, photos, receipts, labels and scans:** JPEG, PNG, WebP, TIFF, BMP, GIF or AVIF, up to 50 MB each.

- **Scanned PDFs, page by page:** each page drawn at 300 DPI and read, one result per page.

- **Turned upright first:** a page scanned on its side or upside down is turned before it's read.

- **The text and a confidence score** for each image or page, and each line's text, confidence and position if you ask.

- **51 languages,** mixed if you like: English, German, French, Spanish, Italian, Portuguese, Dutch, Swedish, Danish,
  Norwegian, Finnish, Polish, Czech, Slovak, Hungarian, Romanian, Bulgarian, Greek, Russian, Ukrainian, Serbian,
  Croatian, Slovenian, the Baltic languages, Catalan, Turkish, Arabic, Hebrew, Persian, Urdu, Hindi, Bengali, Tamil,
  Telugu, Marathi, Gujarati, Kannada, Malayalam, Thai, Vietnamese, Indonesian, Malay, Filipino, Swahili, Afrikaans,
  Chinese (Simplified and Traditional), Japanese and Korean.

It costs **$1.50 per 1,000 images or PDF pages** on Apify's paid plans and $3 on the free plan. A blank page, or an
image that can't be fetched or gives no text, costs nothing. No API key and no outside service: the reading runs
inside the run.

### What people use it for

- **Documents:** receipts, invoices, contracts and forms, photographed or scanned to PDF, as text to parse.
- **AI and RAG pipelines:** the words in scans, charts, slides and screenshots, as text ready to embed.
- **Archives and paperwork:** old scanned reports, letters and contracts made searchable PDFs, findable in a
  document system, Google Drive or Dropbox search.
- **E-commerce and social media:** the text on product images and labels, or in posts' images and carousels, read
  straight from a scraper's dataset.
- **Automation:** image text as one step of a Make, Zapier or n8n workflow, or a tool for an AI agent.

### How to extract text from an image or a scanned PDF

1. Click **Try for free**; Apify's free plan covers a first run.
2. Enter the **Image or PDF URLs**, or pick a dataset under **Images from a dataset**.
3. Pick the **Languages** in your files, if not English, and turn on **Searchable PDF** if you want PDFs.
4. Click **Start**, then download the results as JSON, CSV or Excel.

An input with every option:

```json
{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png",
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf"
  ],
  "datasetId": "YOUR_SCRAPER_RUN_DATASET_ID",
  "imageField": "imageUrl",
  "maxImages": 100,
  "languages": ["eng", "deu"],
  "autoRotate": true,
  "searchablePdf": true,
  "maxPagesPerPdf": 100,
  "includeLines": true
}
```

### Output

A page of a scanned PDF, the second one, which was scanned on its side:

```json
{
  "url": "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf",
  "finalUrl": "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf",
  "fileName": "sample-scan.pdf",
  "format": "PDF",
  "page": 2,
  "pageCount": 2,
  "width": 3301,
  "height": 2550,
  "sizeBytes": 324552,
  "text": "Invoice 2209\n\nDelivered: 14 boxes of paper\nTotal due: $412.75 by 30 December\n\nThis page was scanned on its side.",
  "confidence": 96.3,
  "rotated": 90,
  "searchablePdfUrl": "https://api.apify.com/v2/key-value-stores/30aC21BUvyIHBxwfK/records/00001-sample-scan.pdf?signature=V4RD3odclPKUH2NZq1Lj",
  "error": null,
  "lines": [
    {
      "text": "Invoice 2209",
      "confidence": 96,
      "x": 245,
      "y": 330,
      "width": 510,
      "height": 69
    }
  ]
}
```

An image comes the same way, with `page` and `pageCount` empty. `confidence` is Tesseract's own score from 0 to
100, the mean over the text. `rotated` is the degrees, clockwise, the image was turned to read it. `lines`, with
**Line by line** on, gives each line's position in pixels: of the original image, or of the page drawn at 300 DPI,
as turned upright. `searchablePdfUrl`, with **Searchable PDF** on, opens the file's searchable PDF: every page of
a PDF links to the same one, which holds all the pages read, blank ones included, upright. A file that can't be read
comes with `url` and `error`, saying why.

### Images from a dataset

Give **Images from a dataset** a dataset in your account, such as the default dataset of a run of an Instagram,
product or real estate scraper, and its items' images are read with the rest. Without an **Image field**, it takes
every field named like an image (`image`, `images`, `imageUrl`, `thumbnail`, `photo`, `logo`, `icon`...) holding a
web address, a list of them or objects with a `url`; with one, only that field, a dotted path for one inside another.
**Max files** stops it after that many, and the same address twice is read once. The Actor is given read access to
that dataset only, for that run. In Make, Zapier, n8n or an Apify integration, start it when the scraper's run
finishes, with the run's `defaultDatasetId` as `datasetId`.

### Use it as an API

Apify's API starts a run and returns its dataset as JSON; its Python and JavaScript clients, and
its Make, Zapier and n8n integrations, work the same way.

```bash
curl -X POST "https://api.apify.com/v2/acts/pikoulas~image-ocr/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png"]}'
```

AI agents can call it as a tool through Apify's MCP server: `https://mcp.apify.com?tools=pikoulas/image-ocr`.

### How much does it cost?

An image or a PDF page is $0.0015, whatever its size, and you pay only for those that give text. A thousand
screenshots cost $1.50; a hundred scanned contracts of 20 pages each cost $3. Set a spending limit on a run and it
stops there, with what it has read so far. Searchable PDFs cost nothing more.

### Good to know

- **Printed text reads best.** It uses the Tesseract OCR engine. Clean screenshots and scans come out well; handwriting,
  photos at an angle, stylised type and busy backgrounds can come out wrong, and `confidence` shows it. It doesn't
  describe what an image shows, only reads the words in it.
- **A searchable PDF shows the page as it was read:** in greys, turned upright, and as a JPEG, so it is usually
  smaller than the scan, a few hundred KB a page. The hidden text sits where Tesseract found each word, so selecting
  lines works best on clean scans. Pages past **Max pages per PDF**, or that couldn't be read, aren't in it.
- **A PDF made of text, not scans,** reads faster and for less with [PDF Text Extractor](https://apify.com/pikoulas/pdf-text),
  which takes its text as it stands, as Markdown.
- **Turning upright** needs a few lines of text to be sure; an image with too little is read as it is.
- Of an animated GIF or a TIFF with several pages, only the first is read. Images are read as they are at up to 4,000
  pixels on the longer side, and images over 100 megapixels are refused.
- **Protected PDFs aren't read.** A PDF that needs a password, or whose permissions forbid copying its text, comes back
  with an `error`, and costs nothing.
- **More memory reads faster:** one image or page at a time per GB of memory, up to eight.
- **A site's refusal is respected.** It names itself in its User-Agent and reads each site's `robots.txt`, one request
  a second per site at most. A path `robots.txt` refuses isn't fetched, and a site that answers 401, 403 or 451, shows a
  verification page or answers 429 twice is left alone for the rest of the run; the rest of your list goes on. It uses
  no proxy and doesn't try to get past any of this, so an image behind a check comes back with an `error`.
- Only public addresses are fetched, not private networks.
- **It isn't for captchas.** Don't use it to read captchas or other checks meant to keep automation out.
- **An image's metadata is left out,** GPS and camera details included, and a PDF's too. The text it shows comes as it
  stands, names included.
- **Contact.** The Actor keeps nothing itself: each file stays on disk only while it's being read, and results sit in
  the dataset of whoever ran it. Questions or requests go to spyridwn.pd@gmail.com.
- Reads images with Tesseract OCR and PDFs with PDFium; based in part on the work of the FreeType Team.

### FAQ

#### Is it legal to extract text from images?

It reads only the images you point it at, as anyone could download them, without logging in, and it keeps to each
site's `robots.txt`. You are responsible for having the right to use them: images and the words in them are usually
someone's copyrighted work, a site's terms may limit how you use what it publishes, including using it with AI models,
and personal data in them is protected by laws such as the GDPR and the CCPA. If you're unsure, ask a lawyer;
Apify's [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/) is a good start.

#### Does it read files I upload?

It reads URLs. A file on your own computer needs an address first: upload it to a key-value store in Apify Console
(**Storage**) and give the record's signed URL.

#### Something missing or not working?

Open an issue on the **Issues** tab with the input you used, or ask there for a field you need.

If it does what you need, a review on the **Reviews** tab helps others find it.

# Actor input Schema

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

The addresses of images, or leave it empty and give a dataset below: (JPEG, PNG, WebP, TIFF, BMP, GIF or AVIF) or scanned PDFs, up to 50 MB each. Each page of a PDF is read; of an animated GIF or a TIFF with several pages, only the first.

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

A dataset from your account, such as a social media, product or listing scraper's results: the image addresses of its items are read, from the field below or, without one, from each field named like an image (image, images, photo, thumbnail, logo, icon...).

## `imageField` (type: `string`):

The dataset field the image addresses are in, a dotted path for one inside another: imageUrl, images, post.media. It can hold one address, a list, or objects with a url.

## `maxImages` (type: `integer`):

Read at most this many images or PDFs, from the list and the dataset together. Empty for all.

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

The languages in the images. English alone if left empty. Each one more takes longer, so pick only those you need.

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

Turns an image or page scanned or photographed on its side, or upside down, before reading it. Off reads it as it is, a little faster.

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

Also makes each image or scanned PDF a searchable PDF: the page as it was scanned, with the text found laid under it, invisible, so it can be searched, selected and copied. Linked from each row as searchablePdfUrl, at no extra cost.

## `maxPagesPerPdf` (type: `integer`):

Pages read from the start of each PDF, each charged as an image.

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

Adds each line's text, confidence and position in the image, under lines.

## Actor input object example

```json
{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png",
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf"
  ],
  "languages": [
    "eng"
  ],
  "autoRotate": true,
  "searchablePdf": false,
  "maxPagesPerPdf": 10,
  "includeLines": false
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

## `files` (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 = {
    "urls": [
        "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png",
        "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf"
    ],
    "maxPagesPerPdf": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("pikoulas/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 = {
    "urls": [
        "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png",
        "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf",
    ],
    "maxPagesPerPdf": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("pikoulas/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 '{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample.png",
    "https://api.apify.com/v2/key-value-stores/jw9EhgXyNxeqJScPx/records/sample-scan.pdf"
  ],
  "maxPagesPerPdf": 10
}' |
apify call pikoulas/image-ocr --silent --output-dataset

```

## MCP server setup

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