# PDF & Image to Text \[$2/1K]: OCR for Scans, Markdown & RAG (`robertosan16/pdf-ocr-text-extractor`) Actor

Extract text from PDFs and images by link, upload or dataset. Reads each PDF page's own text and runs OCR only on scanned pages (20 languages incl. Thai, Chinese, Arabic). Markdown, per-page text, RAG chunks with page numbers, metadata.

- **URL**: https://apify.com/robertosan16/pdf-ocr-text-extractor.md
- **Developed by:** [Robert Khairislamov](https://apify.com/robertosan16) (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.40 / 1,000 documents

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

## PDF & Image to Text: OCR for Scans, Markdown & RAG Chunks

**Turn PDFs and images into clean text.** Paste file links, upload a file or point to another Actor's dataset. Each PDF page's own text is read exactly; **only scanned pages go through OCR**, in 20 languages including Thai, Chinese, Japanese, Korean, Arabic and Hindi. You get the full text, Markdown, the text of every page, chunks for RAG with page numbers, and the document's metadata. **$2 per 1,000 documents, plus $3 per 1,000 pages read with OCR.**

### What can it do?

- 📄 **PDFs with text**: the text layer of every page, exact and fast, with no OCR cost.
- 🖨️ **Scanned PDFs and mixed PDFs**: pages without text (scans, photos of pages) are turned into images and read with OCR (Tesseract 5). Text pages of the same file stay exact.
- 🖼️ **Images**: PNG, JPEG, TIFF, WebP, GIF and BMP: screenshots, receipts, invoices, menus, labels, photos of documents.
- 🌏 **20 OCR languages**: English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Turkish, Russian, Ukrainian, Arabic, Hindi, Thai, Vietnamese, Indonesian, Chinese (simplified and traditional), Japanese, Korean. Several at once for mixed documents.
- 🧩 **Ready for LLMs and RAG**: Markdown with a section per page, and chunks of a size you choose, cut at paragraph ends, each with its page numbers for citations.
- 🔎 **Quality you can check**: for every page, whether it came from the text layer or OCR, and the OCR confidence (0-100). Low-confidence pages are flagged.
- 🗂️ **Bulk**: many links in one run, or the file links found in another Actor's dataset (for example the PDFs a crawler found). Page ranges, password-protected PDFs, size and page limits.

### Who uses it

- **AI and RAG builders**: load reports, manuals, contracts and papers into a vector database, with page numbers for citations.
- **Back offices and accountants**: read scanned invoices, receipts and forms in bulk, then search or parse the text.
- **Researchers and analysts**: text from annual reports, tenders, filings and academic papers.
- **Automation (n8n, Make, Zapier)**: a file arrives, the Actor returns its text, the next step uses it.

### How to extract text from PDFs and images

1. Paste **File links** (direct links to the PDF or image), or **upload a file**, or give a **dataset ID** whose items hold links.
2. Choose **OCR**: *Auto* (only pages without text, the default), *Always* or *Never*, and the **OCR languages** of your documents.
3. Run, then download the results as JSON, CSV or Excel, or use them through the API.

#### Example input

```json
{
  "urls": ["https://api.apify.com/v2/key-value-stores/McK7YieXsXVetN4uP/records/sample-invoice-report.pdf?signature=ur72I9CODSvHy1tTWcOr"],
  "ocr": "auto",
  "languages": ["eng", "tha"],
  "includeChunks": true,
  "chunkSize": 1500
}
```

#### Example output

The example file has a report page with a text layer and a scanned invoice page:

```json
{
  "url": "https://…/sample-invoice-report.pdf",
  "fileName": "sample-invoice-report.pdf",
  "fileType": "pdf",
  "pageCount": 2,
  "pagesRead": 2,
  "pagesWithOcr": 1,
  "ocrLanguages": ["eng"],
  "ocrConfidence": 96,
  "title": null,
  "characters": 295,
  "words": 50,
  "text": "Quarterly Report\nRevenue grew by 12 percent in the third quarter…\n\nINVOICE 2026-117\nMozart Standard Co., Pattaya\nTotal due: 4,250.00 THB\n\nPayment within 14 days.",
  "markdown": "## Page 1\n\nQuarterly Report\n\nRevenue grew by 12 percent…\n\n## Page 2\n\nINVOICE 2026-117\n\nMozart Standard Co., Pattaya\n\nTotal due: 4,250.00 THB\n\nPayment within 14 days.",
  "pages": [
    { "page": 1, "method": "text", "characters": 199, "ocrConfidence": null, "text": "Quarterly Report…" },
    { "page": 2, "method": "ocr", "characters": 94, "ocrConfidence": 96, "text": "INVOICE 2026-117…" }
  ],
  "chunks": [{ "index": 0, "pages": [1, 2], "text": "Quarterly Report…" }],
  "warnings": [],
  "processedAt": "2026-11-16T10:00:00.000Z"
}
```

### How much does it cost?

You pay for results only: **$2 per 1,000 documents** read and **$3 per 1,000 pages read with OCR**. That is the price on the Apify Free plan; paid Apify plans pay less. No start fee.

- A 40-page PDF with a text layer: one document, **$0.002**.
- A 10-page scanned PDF: one document and 10 OCR pages, **$0.032**.
- 1,000 receipt photos: 1,000 documents and 1,000 OCR pages, **$5**.

Files that fail (broken links, web pages instead of files, wrong passwords) are not charged. With OCR on *Auto*, pages that already have text never pay for OCR.

### Tips

- **Pick the right languages**: OCR reads only the languages you choose. For a Thai document with English words, choose both Thai and English. Fewer languages are faster and more accurate.
- **Low confidence?** Check the language, and for very small print raise **OCR resolution** to 400.
- **Only a few pages needed?** Use **Pages**, for example `1-3` for the summary of long reports.
- **Large batches**: the run's memory sets the OCR speed: each 4 GB of memory adds a CPU core, and pages are read in parallel.
- **Run summary**: every file with its pages, OCR pages or the reason it failed is in the key-value store as `SUMMARY`.

### FAQ

**Can it read files from Google Drive or Dropbox links?** Not from the links: both sites' robots.txt doesn't allow automated downloads, and this Actor respects robots.txt. Download the file and upload it in the input, or use a direct link from a site that allows downloads.

**Is the text exact?** Text from a PDF's text layer is exactly what the file contains. OCR text is a reading of an image: on clean scans it is usually very accurate (confidence 90+), on photos, handwriting or low resolution less so. Every OCR page has its confidence.

**Does it keep tables and layout?** It returns the text in reading order with paragraphs. Table cells come out as text lines; the layout itself is not kept.

**Are my files stored?** Files are downloaded into the run, read, and deleted when the run ends. Only the results are saved in your own Apify storage.

**What about very long documents?** Dataset records are limited in size, so for very long documents the record holds the first 200,000 characters and `fullContentUrl` links to the full text, Markdown, pages and chunks.

Missing a feature or a language? Open an issue in the Issues tab or email <support@mozartstandard.com>, and we will reply quickly.

If this Actor saved you time, a short review in the **Reviews** tab helps other users find it and helps us keep improving it.

# Actor input Schema

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

Direct links to PDF files or images (PNG, JPEG, TIFF, WebP, GIF, BMP), one per line. Files are downloaded only where the site's robots.txt allows it; for other files (for example Google Drive or Dropbox, which don't allow automated downloads), download the file and upload it below.

## `file` (type: `string`):

Or upload one PDF or image from your computer.

## `ocr` (type: `string`):

PDF pages usually carry their own text, which is read exactly and fast. Scanned pages are images, so they need OCR. <b>Auto</b> runs OCR only on pages with almost no text. Images are always read with OCR.

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

The languages of the scanned text. Pick all languages that appear, for example English and Thai; fewer languages read faster and more accurately.

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

Only these pages of each PDF, for example <code>1-3, 5, 10-</code>. Empty: all pages.

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

Add the text as Markdown, with a section per page, ready for LLMs and notes.

## `includePages` (type: `boolean`):

Add a list of pages with their text, the method (text layer or OCR) and the OCR confidence.

## `includeChunks` (type: `boolean`):

Add the text cut into chunks of about <b>Chunk size</b> characters at paragraph ends, each with its page numbers, ready for a vector database.

## `chunkSize` (type: `integer`):

About this many characters per chunk.

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

The ID of a dataset (for example the results of another Actor) whose items hold file links. Their links are read too.

## `datasetField` (type: `string`):

The field of the dataset items that holds the link (or a list of links).

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

For password-protected PDFs. The same password is used for every file.

## `maxPagesPerDocument` (type: `integer`):

At most this many pages of each PDF are read.

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

Larger files are skipped (not charged).

## `minTextChars` (type: `integer`):

With OCR on Auto, a page with fewer letters and digits than this in its text layer is treated as a scan.

## `ocrDpi` (type: `integer`):

Scanned PDF pages are turned into images at this resolution for OCR. 300 suits most documents; raise it for very small print.

## Actor input object example

```json
{
  "urls": [
    "https://api.apify.com/v2/key-value-stores/McK7YieXsXVetN4uP/records/sample-invoice-report.pdf?signature=ur72I9CODSvHy1tTWcOr"
  ],
  "ocr": "auto",
  "languages": [
    "eng"
  ],
  "includeMarkdown": true,
  "includePages": true,
  "includeChunks": false,
  "chunkSize": 1500,
  "datasetField": "url",
  "maxPagesPerDocument": 500,
  "maxFileSizeMb": 100,
  "minTextChars": 25,
  "ocrDpi": 300
}
```

# Actor output Schema

## `documents` (type: `string`):

One record per file: text, Markdown, pages, chunks and metadata.

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

Every file with its result, pages, OCR pages or the reason it failed.

# 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/McK7YieXsXVetN4uP/records/sample-invoice-report.pdf?signature=ur72I9CODSvHy1tTWcOr"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("robertosan16/pdf-ocr-text-extractor").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/McK7YieXsXVetN4uP/records/sample-invoice-report.pdf?signature=ur72I9CODSvHy1tTWcOr"] }

# Run the Actor and wait for it to finish
run = client.actor("robertosan16/pdf-ocr-text-extractor").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/McK7YieXsXVetN4uP/records/sample-invoice-report.pdf?signature=ur72I9CODSvHy1tTWcOr"
  ]
}' |
apify call robertosan16/pdf-ocr-text-extractor --silent --output-dataset

```

## MCP server setup

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

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/696w6pn0bgasIeO06/builds/YaJ3b8zBcBcCLGYld/openapi.json
