# PDF OCR to Markdown: Scans, Images, Tables (`brasspage/pdf-ocr-to-markdown`) Actor

Returns clean Markdown or plain text for each PDF or image (PNG, JPG, WEBP, TIFF): tables as Markdown tables, a per-page array and a .md file. OCR for scanned and digital PDFs with Google Gemini vision. Page ranges. For RAG, LLMs and AI agents. From $0.006 per page.

- **URL**: https://apify.com/brasspage/pdf-ocr-to-markdown.md
- **Developed by:** [Brasspage](https://apify.com/brasspage) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $6.00 / 1,000 page converteds

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

### PDF OCR to Markdown: scanned PDFs and images to clean Markdown

Convert **scanned PDFs, digital PDFs and images** (PNG, JPG, WEBP, TIFF) to clean **Markdown** or plain text. Tables become Markdown tables, headings stay headings, and math becomes LaTeX. For every document you get the full text, a **per-page array**, the page count and a downloadable `.md` file.

A vision AI model (Google Gemini 3.1 Flash-Lite) reads each page as an image, so it works on scans, photos of paper, faxes and PDFs with no text layer, where plain text extraction returns nothing.

**Price: $0.006 per page**, including up to 2,000 output tokens (about 1,500 words). Very dense pages, such as tables full of numbers, cost $0.003 more per extra 1,000 tokens. A 10-page scanned contract costs about $0.065. On the Apify free plan, you can try 20 pages per run and 50 pages per month (see [Limits](#limits)).

### What you get

For each PDF or image, one row with:

- **Clean Markdown or plain text** for the whole document: tables as Markdown tables, headings kept, math as LaTeX.
- **A per-page array**, so you can quote, chunk or index page by page.
- **A `.md` file** to download.
- **The page count** and the number of pages converted.
- **No charge for failures:** a page or file that fails is marked with an `error`.

### Quick start

1. Keep the prefilled IRS Form W-9 PDF, or paste links to your own PDFs or images.
2. Optional: set **Pages** (for example `1-3`) and choose Markdown or plain text.
3. Click **Start**. The 6-page W-9 is ready in about 10 seconds and costs $0.044.
4. Read the Markdown in the **Output** tab, or download the `.md` file.

### What you can do with it

- **RAG and LLM pipelines:** turn PDFs into Markdown that chunks well. Use `pages[]` to keep page numbers for citations.
- **AI agents:** give an agent one tool that reads any PDF or image link and returns text. MCP URL below.
- **Scanned archives:** old reports, typewritten letters, faxes and multi-page TIFF scans to searchable text.
- **Tables to data:** invoices, price lists, statements and data tables as Markdown pipe tables, or as tab-separated rows that paste straight into a spreadsheet.
- **Forms and receipts:** get the printed text and labels of forms, receipts and IDs you are allowed to process.

### How it works

1. You give direct links to PDF or image files, or upload a file.
2. The Actor downloads each file from public hosts only, checks its real type from its first bytes, and splits PDFs and multi-page TIFFs into single pages.
3. Each page goes to Gemini 3.1 Flash-Lite with fixed instructions: transcribe exactly, in reading order, keep the original language, do not summarize or add anything. Up to 8 pages are read at the same time.
4. You get one dataset item per document, plus a `document-NNNN.md` (or `.txt`) file in the run's key-value store.

### Input

| Field            | Description                                                                                                                               |
| ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| `documentUrls`   | Direct links to PDF, PNG, JPEG, WEBP or TIFF files, up to 100 MB each. Apify key-value store record URLs also work (private stores too).  |
| `documentFile`   | Upload one PDF or image from your computer.                                                                                               |
| `pages`          | Pages to convert in each document, for example `1-3, 5, 10-` (`10-` means page 10 to the end). Empty means all pages. An image is page 1. |
| `outputFormat`   | `markdown` (default) or `text` (no Markdown formatting).                                                                                  |
| `markdownTables` | `true` (default): tables as Markdown pipe tables, also in plain text output. `false`: one row per line, cells separated by tabs.          |
| `maxPagesPerRun` | Safety limit: total pages per run (default 1000).                                                                                         |

#### Example input

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://example.com/scanned-invoice.jpg"
  ],
  "pages": "1-2",
  "outputFormat": "markdown",
  "markdownTables": true
}
```

### Output

One dataset item per document:

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileType": "pdf",
  "pageCount": 6,
  "pagesConverted": 2,
  "markdown": "# Form W-9\n(Rev. March 2024)\n...\n\n# Part I Taxpayer Identification Number (TIN)\n...",
  "pages": [
    { "page": 1, "markdown": "# Form W-9\n(Rev. March 2024)\n..." },
    { "page": 2, "markdown": "Form W-9 (Rev. 3-2024) Page 2\n..." }
  ],
  "outputFormat": "markdown",
  "model": "gemini-3.1-flash-lite",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/.../records/document-0001.md",
  "convertedAt": "2026-10-15T15:50:03+00:00"
}
```

- `markdown` is all converted pages joined with a blank line. With `outputFormat: text`, the field is `text` instead, in the item and in `pages[]`.
- `pageCount` is the number of pages in the file. `pagesConverted` is the number of pages you get text for.
- Each page in `pages[]` has `outputTokens`, the size of its text. `extraTokenBlocks` is the number of extra 1,000-token blocks charged for the document (see [Pricing](#pricing)).
- A page whose text is longer than the limit of 8,192 output tokens is cut there and has `"truncated": true`. You get and pay for the text up to the limit. This is rare: the densest page we tested, a full IRS tax table, needs about 6,500.
- A page that fails has `{ "page": 4, "error": "..." }` in `pages[]`, and you are not charged for it.
- A file that fails (a 404, a web page instead of a file, a password-protected PDF) gives an item with an `error` field, and you are not charged for it.

### Pricing

Pay per event. There is no monthly fee.

| Event             | Price                                                                      |
| ----------------- | -------------------------------------------------------------------------- |
| Actor start       | $0.005 per run                                                             |
| `page-converted`  | $0.006 per page that you get text for, including up to 2,000 output tokens |
| `extra-1k-tokens` | $0.003 per started 1,000 output tokens above 2,000 on one page             |

Examples: one typed letter costs $0.011. The 6-page IRS Form W-9 costs $0.044 (one page has 2,130 tokens, so it adds one extra block). A full page of a tax table with about 6,500 tokens costs $0.021. 1,000 pages of normal text cost about $6. The most one page can cost is $0.027.

Set **Maximum cost per run** in the run options to cap your spending. The Actor starts a page only if its highest possible price still fits in the remaining budget, so a run never goes over your maximum.

#### Limits

- **Max pages per run** (`maxPagesPerRun`, default 1000). The run stops when it reaches this total, and the last dataset row has a `note` that says so. Raise the limit or start another run for more.
- **Apify free plan: free trial of 20 pages per run and 50 pages per month.** On the free plan, the Actor converts up to 20 pages per run, then stops with a note. After 50 pages in a calendar month (UTC), runs return only a note until the 1st of the next month. To convert more, upgrade to a [paid Apify plan](https://apify.com/pricing).
- Files up to 100 MB, pages up to 14 MB each, and up to 5,000 pages per document.
- Supported: PDF, PNG, JPEG, WEBP and TIFF. Word, Excel and PowerPoint files are not supported; export them to PDF first.

### FAQ

**How accurate is it?**
Very good on printed text, typewriter pages and clean scans. Like every OCR tool, it can misread small digits in dense tables, faint scans or messy handwriting. Check important numbers against the original. Unreadable words are marked `[illegible]`.

**Does it work on PDFs that already have text?**
Yes. Every page is read as an image, so digital and scanned PDFs give the same kind of Markdown, with the layout, tables and reading order of what you see on the page.

**Can text in a document trick the AI?**
The page goes to the model only as file data, with fixed instructions to transcribe it and never follow instructions in it. The model has no tools and no internet access, and its answer is only ever stored as that page's text. In our tests, a page that says "ignore all previous instructions" is transcribed word for word.

**Where do my documents go?**
The Actor sends each page to Google's Gemini API on a paid plan. Google does not use paid API data to improve its products. It keeps it for a limited time to detect abuse. The Actor keeps no copy after the run, except the results in your own Apify storage.

**What is the difference between Markdown and plain text output?**
Markdown keeps headings (`#`), lists, bold text and LaTeX math, which LLMs and RAG tools read well. Plain text has no formatting. In both, tables are Markdown tables unless you turn off **Tables as Markdown tables**.

**How fast is it?**
About 2 to 5 seconds per page, with 8 pages read at a time, so a 100-page PDF should take 1 to 2 minutes.

**How do I use it from an AI agent or my code?**
Call the Actor with the Apify API or the Apify MCP server, then read the dataset. To give an AI agent this one tool, connect it to the Apify MCP server at `https://mcp.apify.com?tools=brasspage/pdf-ocr-to-markdown`.

**Who is responsible for the rights to the documents?**
You are. Only convert documents that you own, that are public, or that you have permission to process. The Actor does not try to get around paywalls, logins or PDF passwords.

**Something does not work?**
Open an issue on the Issues tab with the run URL. Fixes are usually quick.

### Related Actors

Other tools from the same developer, with the same pay-per-result pricing:

- [Podcast & Audio Transcriber](https://apify.com/brasspage/media-transcriber): podcasts and audio or video files to text, SRT and VTT subtitles.
- [Google Sheets Export & Sync](https://apify.com/brasspage/google-sheets-sync): send the results of any Actor to a Google Sheet (append, replace or upsert).
- [Website Contacts & Tech Stack](https://apify.com/brasspage/website-contact-tech-audit): public emails, phones, social links, CMS and pixels for a list of websites.
- [ATS Jobs API](https://apify.com/brasspage/careers-site-jobs-api): every open job from Greenhouse, Lever, Ashby and other ATS boards, with new-job alerts.

# Actor input Schema

## `documentUrls` (type: `array`):

Direct links to PDF, PNG, JPEG, WEBP or TIFF files, up to 100 MB each. Scanned and digital PDFs both work. Apify key-value store record URLs also work (private stores in your account too).

## `documentFile` (type: `string`):

Upload one PDF or image from your computer.

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

Optional. Pages to convert in each document, for example 1-3, 5, 10- (10- means page 10 to the end). Leave empty for all pages.

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

Markdown keeps headings, lists, bold text and math. Plain text has no Markdown formatting.

## `markdownTables` (type: `boolean`):

On: tables become Markdown pipe tables (also in plain text output). Off: one table row per line, cells separated by tabs.

## `maxPagesPerRun` (type: `integer`):

Safety limit. The run stops after this many pages in total, and the last dataset row says so. On the Apify free plan, runs are a free trial of up to 20 pages per run and 50 pages per month; upgrade to a paid Apify plan to convert more.

## Actor input object example

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "outputFormat": "markdown",
  "markdownTables": true,
  "maxPagesPerRun": 1000
}
```

# Actor output Schema

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

One item per document: URL, file type, page count, pages converted, the full Markdown (or plain text), and a pages array with the text or the error of each page. A last row with a note appears when the run stops at its page limit.

## `files` (type: `string`):

Key-value store with one document-NNNN.md (or .txt) file per converted document.

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

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

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

```

## MCP server setup

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

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/PRRp7IZzgjgb2ScB2/builds/YX9sUHfUyKXkRkCmT/openapi.json
