# Image to Text OCR - Read Text from Images, Scans & PDFs (`akhil_rajesh/image-to-text-ocr`) Actor

OCR for images, scans and PDFs: text, Markdown and each line's position per image or page, plus QR codes and barcodes. Reads JPEG, PNG, HEIC, TIFF and PDF links (page ranges, passwords), uploads and other Actors' datasets. Pages without text are free.

- **URL**: https://apify.com/akhil_rajesh/image-to-text-ocr.md
- **Developed by:** [Akhil rajesh](https://apify.com/akhil_rajesh) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.40 / 1,000 pages with text

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/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: read text from images, scans and PDFs

Image to Text OCR reads the text in **images, photos, scans and PDFs**. It gives you one row per image or PDF page with:

- the full text in reading order;
- the page as **Markdown**;
- every line with its confidence and position;
- any **QR codes and barcodes** on the page.

Give it links, upload files, paste base64 images, or point it at another Actor's dataset of image links.

- **Images:** JPEG, PNG, WebP, GIF, BMP, TIFF (every page of a multi-page TIFF), JPEG 2000, and iPhone **HEIC** and **AVIF**
  photos. Phone photos are turned upright by their EXIF orientation. Transparent PNGs are read on white.
- **PDFs:**
  - A page that carries its own text (most PDFs made on a computer) is read from that text. This is exact and fast, and
    keeps headings, paragraphs and tables in its Markdown. Scanned pages are read with OCR at the scan's own resolution.
  - Choose pages with a range such as `1-5, 8, 12-`, and open password-protected PDFs with their password.
  - Each row carries the PDF's title, author and dates.
- **Links that aren't the file itself:** Dropbox and Google Drive share links are turned into download links. An article
  page that names its PDF (arXiv, journals, repositories) is followed to the PDF.
- **Languages:** English, Chinese and Japanese, and about 50 Latin-script languages out of the box (French, German, Spanish,
  Portuguese, Italian, Dutch, Polish, Turkish, Vietnamese, Indonesian...). Also Korean, Russian and Ukrainian, other Cyrillic
  languages, Arabic script, Devanagari (Hindi), Thai, Greek, Tamil, Telugu and Kannada.
- **Positions:** each line's box (four corners in pixels, and as 0-1 fractions of the page) and confidence. Optionally
  each word's box too, for redaction, form reading or layout work.
- **Only pages with text or a code are charged.** Blank pages, broken links and files that can't be read get a free row
  that says why.

OCR runs on Apify's servers with PaddleOCR's PP-OCR models (through RapidOCR, Apache-2.0). Barcodes are read with
zxing-cpp, and PDF layout with LiteParse. Your files aren't sent to any other service.

### How to use it

1. Paste links to images or PDFs into **Image and PDF links**, one per line, or upload files.
2. Leave **Language** on Auto unless the text is in one of the other scripts listed above.
3. Run it. Each image or PDF page becomes a row in the dataset. The **Text** view shows the text, **Markdown** the
   page as Markdown, **Lines with positions** each line's box, and **QR codes and barcodes** what the codes say.

A link should lead to the file itself (`.../photo.jpg`, `.../report.pdf`). If it returns a web page that doesn't name a
PDF, the row says so.

#### Read images another Actor found

Pick that run's dataset in **Dataset with links**. The Actor looks in the usual fields (`url`, `imageUrl`, `fileUrl`,
`image`, `pdfUrl`, `displayUrl`, `images`...), or in the one you name in **Field with the links**. Dots reach nested
fields (`media.photos`), and a field holding a list of links gives every link in it.

#### Input example

```json
{
  "files": [
    "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
    "https://example.com/invoices/march.pdf"
  ],
  "language": "auto",
  "mode": "accurate",
  "pdfText": "auto",
  "pages": "1-5",
  "maxPagesPerFile": 100,
  "maxPages": 1000,
  "minConfidence": 0.5,
  "includeLines": true,
  "includeMarkdown": true,
  "readCodes": true,
  "includeWords": false
}
```

Other Actors' input names work too:

- for links: `urls`, `imageUrls`, `documentUrls`, `pdfUrls`, `startUrls`, `imagesBase64` and `inputDatasetId`;
- for pages: `maxPdfPages` and `pageRange`;
- for PDF text: `pdfTextMode` (`auto`, `ocr`, `text_only`) and `ocrScannedPages: false`;
- for languages: `languages`, as two- or three-letter codes such as `en`, `ko`, `ru`, `ar`, `hi`, `kn`.

### Output

One row per image or PDF page:

```json
{
  "input": "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
  "url": "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
  "fileName": "ReceiptSwiss.jpg",
  "fileType": "image",
  "page": 1,
  "pageCount": 1,
  "status": "found",
  "statusReason": null,
  "textSource": "ocr",
  "text": "Berghotel\nGrosse Scheidegg\n3818 Grindelwald\nFamilie R.Müller\nRech.Nr. 4572\t30.07.2007/13:29:17 ...",
  "charCount": 412,
  "lineCount": 31,
  "meanConfidence": 0.9913,
  "markdown": "## Berghotel\nGrosse Scheidegg\n3818 Grindelwald ...",
  "lines": [
    {"text": "Berghotel", "confidence": 0.9981, "box": [[262, 96], [457, 96], [457, 134], [262, 134]],
     "boxNorm": [[0.1638, 0.045], [0.2856, 0.045], [0.2856, 0.0628], [0.1638, 0.0628]]}
  ],
  "codes": null,
  "codeCount": 0,
  "pdfMetadata": null,
  "width": 1600,
  "height": 2133,
  "mode": "accurate",
  "language": "auto",
  "readAt": "2026-12-03T18:20:00Z"
}
```

| Field | What it holds |
|---|---|
| `status` | `found`: text or a code was read (charged). `noText`: no text on that page or image (free). `notLoaded`: the file couldn't be downloaded (free). `robotsDisallowed`: the site's robots.txt doesn't allow automated access to the link (free). `unsupported`: not an image or PDF, too large, damaged, or a PDF whose password is missing or wrong (free). `error`: an error in this Actor (free). |
| `textSource` | `ocr` (read from the pixels) or `pdfText` (the PDF page's own text, exact). |
| `text` | The page's text in reading order. Pieces on one row are joined by a space, or by a tab across a wide gap (receipts, tables). |
| `markdown` | The page as Markdown. A PDF's own text gets it from the PDF's layout (headings, paragraphs, tables as Markdown tables). OCR'd pages get it from the lines' sizes and gaps: taller lines become headings, gaps start paragraphs, and far-apart pieces are separated by `\|`. |
| `lines` | Each OCR line's text, confidence (0 to 1), `box` (four `[x, y]` corners in the pixels of `width` x `height`, clockwise from the top left) and `boxNorm` (the same corners as 0-1 fractions). With **Include words**, each line also lists its `words` with their own boxes. Empty for a PDF's own text. |
| `codes` | Each QR code or barcode: `format` (`QRCode`, `DataMatrix`, `PDF417`, `EAN13`, `Code128`...), `text`, `box` and `boxNorm`. |
| `pdfMetadata` | The PDF's own `title`, `author`, `subject`, `keywords`, `creator`, `producer`, `createdAt` and `modifiedAt`, as far as it has them. |
| `meanConfidence` | The OCR's confidence over the page, weighted by characters. |

A file that can't be read at all gets one row with `page` empty and the reason in `statusReason`. The run's summary is
saved as `RUN_SUMMARY` in the key-value store.

### Speed, size and limits

- **Accurate** (default) takes about 3 seconds per image or scanned page at 2 GB of memory. **Fast** takes about half
  that, with slightly less exact reading of small or blurred text. A PDF page read from its own text takes milliseconds.
- More memory gives OCR more CPU: Apify gives a run one core per 4 GB. 2 GB is the cheapest per page.
- Files up to 60 MB; images up to 80 megapixels (larger JPEGs are read at a reduced size). Images are read at up to
  4,000 pixels on their longer side.
- **Pages** picks pages of each PDF and multi-page TIFF. **Max pages per file** (100) and **Max pages and images**
  (1,000) cap long PDFs and big lists.
- A server that refuses or fails (HTTP 429 or 5xx, a dropped connection) is asked twice more, after 2 and 5 seconds, or
  after its own `Retry-After`.
- A run that is stopped, migrated or timed out keeps what it read. Resurrect it to continue: pages already in the dataset
  aren't read or charged again.

### Sites that don't allow automated access

The Actor reads each site's robots.txt before downloading from it. A link the site doesn't allow is reported as
`robotsDisallowed` and isn't fetched. When a site's robots.txt doesn't answer, nothing is fetched from that site in the
run. Upload such files yourself, or link a copy you host.

### Not supported yet

- Handwriting: printed text reads well; neat handwriting partly; cursive poorly.
- Text in more than one script on the same page reads best with Auto when one of the scripts is Latin, Chinese or
  Japanese. For other mixes, run once per language.
- QR codes and barcodes on PDF pages read from their own text aren't decoded (only on images and OCR'd pages).

### Pricing

You pay per image or PDF page where text or a code was found. Pages without text, broken links, links a site's
robots.txt doesn't allow, and unreadable files are free.

| Apify plan | Per 1,000 pages with text |
|---|---|
| Free | $2.00 |
| Starter (Bronze) | $1.80 |
| Scale (Silver) | $1.60 |
| Business (Gold) and above | $1.40 |

Apify also charges a start fee of $0.00005 per GB of memory, which is $0.0001 at the default 2 GB. A 10-page scanned PDF
costs 2 cents on the Free plan.

# Actor input Schema

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

Links to images (JPEG, PNG, WebP, GIF, BMP, TIFF, HEIC, AVIF, JPEG 2000) or PDFs, one per line. Each image and each PDF page becomes one row with its text. Dropbox and Google Drive share links and article pages that name their PDF (arXiv, journals) are followed to the file. data: URLs work too.

## `uploadedFiles` (type: `array`):

Images or PDFs from your computer. They are stored in a key-value store in your account and read from there.

## `inputDataset` (type: `string`):

Read the text of images or PDFs another Actor found: pick its dataset. Links are taken from the field below, or from the usual fields (url, imageUrl, fileUrl, image, pdfUrl, displayUrl, images...).

## `datasetUrlField` (type: `string`):

The dataset field that holds the links, such as imageUrl, or images for a list. Use dots for nested fields (media.0.url). Leave empty to try the usual fields.

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

Accurate reads small and blurred text better. Fast uses a smaller recognition model for clean scans and screenshots. Both use the same text finder. Fast applies to the Auto language only.

## `language` (type: `string`):

The script of the text. Auto covers English, Chinese, Japanese and about 50 Latin-script languages. For other scripts, choose the language: one per run.

## `pdfText` (type: `string`):

Most PDFs made on a computer carry their text, which is exact and fast to read. Scans don't, and are read with OCR. Choose OCR every page when a PDF's own text is garbled.

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

Read only these pages of each PDF or multi-page TIFF, such as 1-5, 8, 12- (page 12 to the end) or -3 (the last three). Leave empty for every page.

## `pdfPassword` (type: `string`):

The password of password-protected PDFs. It is used for every PDF in the run, and never logged.

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

Read at most this many pages of each PDF or multi-page TIFF, from the first (or from the first page named in Pages).

## `maxPages` (type: `integer`):

Stop after this many pages and images in all. Each one with text is a result.

## `minConfidence` (type: `number`):

Leave out lines the OCR is less sure of than this (0 to 1). Real text usually scores above 0.8; 0.5 drops most noise from photos.

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

Add each line's text, confidence and box (four corners in pixels) to the row. Turn off for text only.

## `includeMarkdown` (type: `boolean`):

Add each page as Markdown: headings, paragraphs and table rows, for AI tools and RAG pipelines. PDF pages with their own text get it from the PDF's layout.

## `readCodes` (type: `boolean`):

Also decode QR codes, Data Matrix, PDF417, EAN, UPC, Code 128 and other barcodes on images and OCR'd pages. Free: a page with only a code counts as one result.

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

Add each word with its own box and confidence inside each line (bigger rows). Line boxes come in pixels and as 0-1 fractions of the page either way.

## Actor input object example

```json
{
  "files": [
    "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/3/3b/Typewritten_letter_from_the_Savage_Arms_Parts_Department_%281961%29.jpg"
  ],
  "mode": "accurate",
  "language": "auto",
  "pdfText": "auto",
  "maxPagesPerFile": 100,
  "maxPages": 1000,
  "minConfidence": 0.5,
  "includeLines": true,
  "includeMarkdown": true,
  "readCodes": true,
  "includeWords": false
}
```

# Actor output Schema

## `text` (type: `string`):

No description

## `markdown` (type: `string`):

No description

## `lines` (type: `string`):

No description

## `codes` (type: `string`):

No description

## `problems` (type: `string`):

No description

## `allData` (type: `string`):

No description

## `runSummary` (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 = {
    "files": [
        "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/3/3b/Typewritten_letter_from_the_Savage_Arms_Parts_Department_%281961%29.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("akhil_rajesh/image-to-text-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 = { "files": [
        "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/3/3b/Typewritten_letter_from_the_Savage_Arms_Parts_Department_%281961%29.jpg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("akhil_rajesh/image-to-text-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 '{
  "files": [
    "https://upload.wikimedia.org/wikipedia/commons/0/0b/ReceiptSwiss.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/3/3b/Typewritten_letter_from_the_Savage_Arms_Parts_Department_%281961%29.jpg"
  ]
}' |
apify call akhil_rajesh/image-to-text-ocr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,akhil_rajesh/image-to-text-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/Htsv1nxptsZZzG3HW/builds/vIJITVDrXfFmaUwBI/openapi.json
