# PDF & Image to Markdown/Text — OCR, Tables, RU/KZ/EN (`intrepid_card/pdf-image-to-markdown-ocr`) Actor

Convert PDFs and images to clean Markdown or plain text for LLMs, RAG and data pipelines. Reads the text layer directly and OCRs only scanned pages (Tesseract, 12 languages incl. Russian and Kazakh). Headings, lists and tables preserved. Pay per page; blank pages free.

- **URL**: https://apify.com/intrepid_card/pdf-image-to-markdown-ocr.md
- **Developed by:** [Temirlan Zhussipov](https://apify.com/intrepid_card) (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 $3.50 / 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.
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 Markdown/Text — OCR, tables, Russian & Kazakh

Turn **PDFs and images into clean Markdown or plain text** — ready for LLMs, RAG pipelines, search indexes and data entry. Digital PDFs are read straight from their text layer (fast, exact); **scanned pages and images are OCR'd** automatically. Headings, bullet lists and tables are preserved.

### Why this Actor

- **Smart OCR (Auto mode).** Each page is checked: if it has a text layer it's extracted directly, only scanned pages go through OCR. Mixed documents (digital + scanned pages) just work — and you don't pay OCR prices for digital pages.
- **LLM-ready Markdown.** Headings (`#`, `##`, `###`) detected from font sizes, bullet and numbered lists, paragraphs re-joined across line breaks, hyphenation fixed.
- **Tables.** Ruled tables in digital PDFs become Markdown tables *and* structured rows (`tables`) — no duplicated table text in paragraphs.
- **12 OCR languages**, including **Russian, Kazakh (ә ғ қ ң ө ұ ү һ і), Ukrainian**, English, German, French, Spanish, Italian, Portuguese, Polish, Turkish, Dutch.
- **Per-page or per-document output.** Split by page for RAG chunking, or get one item per document.
- **Robust & safe.** Every document is processed in an isolated process with a timeout and file-size/page limits; corrupt pages don't lose the rest of the document.
- **Fair pricing.** Pay per page; **blank pages and failed downloads are free**.

### Input

| Field | Description |
|---|---|
| **Document URLs** | Direct links to PDFs or images (PNG, JPEG, TIFF incl. multi-page, WebP, GIF, BMP). |
| Output format | `markdown` (default), `text`, or `both`. |
| OCR mode | `auto` (default) — OCR only pages without text; `always`; `never`. |
| OCR languages | One or more of the 12 supported languages (default English). |
| Pages | e.g. `1-3,7,10-`. Empty = all pages. |
| One result per page | One dataset item per page instead of per document. |
| Extract tables | On by default. |
| Limits | Max pages per document (100), max file size (50 MB), OCR DPI (300), timeout per document (900 s). |

```json
{
  "sources": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"],
  "outputFormat": "markdown",
  "ocrMode": "auto",
  "languages": ["eng", "rus", "kaz"]
}
```

### Output

One item per document (default):

```json
{
  "url": "https://example.com/report.pdf",
  "fileName": "report.pdf",
  "kind": "pdf",
  "pageCount": 12,
  "pagesProcessed": 12,
  "textLayerPages": 10,
  "ocrPages": 2,
  "emptyPages": 0,
  "markdown": "# Quarterly Report 2026\n\nRevenue grew…\n\n| Region | Q2 | Q3 |\n| --- | --- | --- |\n…",
  "tables": [{ "page": 1, "rows": [["Region", "Q2", "Q3"], ["Kazakhstan", "120", "150"]] }],
  "ocrMeanConfidence": 91.4,
  "metadata": { "Title": "Quarterly Report", "Author": "…", "CreationDate": "…" },
  "ocrLanguages": ["eng"]
}
```

Pages in the combined `markdown` are separated by `---`. With **One result per page**, each item has `page`, `method` (`text-layer` / `ocr` / `empty`), `markdown`/`text`, `tables` and `ocrConfidence`.
Failed downloads produce an item with an `error` field (not charged). A run summary is saved as `SUMMARY` in the key-value store.

### Pricing

Pay per event:

- **Page (text layer)** — a page whose text was read directly from the PDF.
- **OCR page** — a page or image that was OCR'd and produced text.

Blank pages, failed pages and failed downloads are free.

### Tips

- Use **Auto** OCR mode — it's both the fastest and cheapest.
- Choose only the OCR languages you need; every extra language slows OCR.
- For very small print, raise OCR DPI to 400; for speed on clean scans, 200 is often enough.
- Password-protected PDFs aren't supported.

### Privacy

Files are downloaded only for the duration of the run and are not stored anywhere except your own run's dataset. Only `http(s)` URLs to public hosts are accepted.

### Under the hood

Text layer: [pdfplumber](https://github.com/jsvine/pdfplumber) (MIT). Rendering: [PDFium via pypdfium2](https://github.com/pypdfium2-team/pypdfium2) (BSD-3/Apache-2.0). OCR: [Tesseract](https://github.com/tesseract-ocr/tesseract) (Apache-2.0).

# Actor input Schema

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

Direct links to PDF files or images (PNG, JPEG, TIFF incl. multi-page, WebP, GIF, BMP). The file type is detected from the content.

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

Markdown keeps structure for LLM/RAG use; plain text is the simplest.

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

Auto is fastest and cheapest: digital PDFs are read directly, scanned pages are OCR'd. Images are always OCR'd unless 'Never'.

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

Languages used for OCR. Pick only those present in your documents — each extra language slows OCR down.

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

Optional page selection, e.g. "1-3,7,10-". Empty = all pages (up to the per-document limit).

## `splitPages` (type: `boolean`):

Output one dataset item per page instead of one per document (handy for chunking in RAG pipelines).

## `extractTables` (type: `boolean`):

Detect ruled tables in digital PDFs and output them as Markdown tables plus structured rows.

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

Safety cap; the first N selected pages are processed.

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

Larger files are skipped with an error message.

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

Rendering resolution for scanned PDF pages. 300 is a good default; use 200 for speed or 400 for tiny print.

## `documentTimeoutSecs` (type: `integer`):

Each document is processed in an isolated process that is stopped after this time.

## Actor input object example

```json
{
  "sources": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "outputFormat": "markdown",
  "ocrMode": "auto",
  "languages": [
    "eng"
  ],
  "splitPages": false,
  "extractTables": true,
  "maxPagesPerDocument": 100,
  "maxFileSizeMb": 50,
  "ocrDpi": 300,
  "documentTimeoutSecs": 900
}
```

# Actor output Schema

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

Extracted Markdown/text per document or page.

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

Counts of documents, text-layer pages, OCR pages, empty pages and failures.

# 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": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("intrepid_card/pdf-image-to-markdown-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": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("intrepid_card/pdf-image-to-markdown-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": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ]
}' |
apify call intrepid_card/pdf-image-to-markdown-ocr --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,intrepid_card/pdf-image-to-markdown-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/zVr2GJHLY7IfdZ9SI/builds/2SZ9IuKGSg5f4QHyN/openapi.json
