# PDF & Image OCR to Text and Markdown (`klarto/pdf-ocr-markdown`) Actor

PDF & image OCR to text and Markdown: reads the PDF text layer and runs Tesseract OCR only on scanned pages and images (PNG, JPG, TIFF, WEBP) in 19 languages. Keeps headings, lists and the ruled tables of digital PDFs. Batch URLs. From $0.001 per text page, $0.005 per OCR page; failed pages free.

- **URL**: https://apify.com/klarto/pdf-ocr-markdown.md
- **Developed by:** [Klarto](https://apify.com/klarto) (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 $0.70 / 1,000 pdf text-layer 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 OCR to Text and Markdown

**PDF and image OCR to text and Markdown**: give file URLs and get clean, LLM-ready Markdown and plain text for each file. The Actor reads the PDF text layer where there is one and runs Tesseract OCR only on scanned pages and images. **$0.001 per text-layer page, $0.005 per OCR page.**

Why use it:

- **You pay OCR prices only where OCR is needed.** Pages with a usable text layer cost $0.001; blank pages, failed pages and failed files are free.
- **Markdown that keeps the structure:** headings from font sizes, bullet and numbered lists, ruled tables of digital PDFs, re-joined hyphenated words, and repeated headers and footers removed.
- **19 OCR languages** with Tesseract 5.5, and scans turned by 90° or 180° are rotated automatically.
- **Batch of up to 1,000 URLs.** A bad file does not stop the rest, and each unique URL gets a record with `status` and `error` (if a result cannot be saved, a free `error` record takes its place).
- **Your files stay on Apify.** OCR runs inside the Actor's container; files are not sent to outside AI or OCR services.

### What it does

- **Input:** direct links to PDFs and images (PNG, JPEG, TIFF incl. multi-page, WEBP, BMP, GIF). Dropbox share links and Google Drive file links are converted to direct downloads.
- **Output:** one dataset item per unique URL with `markdown`, `text`, page counts, OCR confidence and PDF metadata (title, author, creation date). An optional `pages` list gives each page's text and method, for citations and RAG chunking.
- **Run summary:** the `OUTPUT` record in the key-value store counts files that are ok, partial, failed and skipped, plus text-layer and OCR pages.

### How it works

1. **Download.** Each URL must be `http` or `https` and point to a public address; every redirect is checked too. Connection errors, timeouts, HTTP 429 and 5xx are retried twice (after 2 s and 5 s). Requests send the User-Agent `Klarto-DocOCR/0.1 (+https://apify.com/klarto)`.
2. **File type.** It is read from the file's first bytes, not from the extension.
3. **PDF text layer.** [pdfplumber](https://github.com/jsvine/pdfplumber) and [pdfminer.six](https://github.com/pdfminer/pdfminer.six) read each page's text, font sizes and ruled tables, with a 60-second limit per page. A page goes to OCR when its text layer is missing or has fewer than 20 characters, when more than 10 % of its glyphs cannot be mapped to letters, or when images cover at least 30 % of the page and the text layer has fewer than 200 characters (a scan with a short stamp).
4. **OCR.** The page is rendered at 300 DPI (by default) with [pypdfium2](https://github.com/pypdfium2-team/pypdfium2) and read by [Tesseract 5.5](https://github.com/tesseract-ocr/tesseract) (LSTM engine) in your languages. Blank pages are detected first and skipped. Orientation detection runs only when the first pass looks poor (confidence below 60 or fewer than 8 words).
5. **Markdown.** Font sizes become `#`, `##` and `###` headings; bullets and numbers become lists; ruled tables become Markdown tables. On OCR pages, large single lines become headings and the rest becomes paragraphs and lists.
6. **Save, then charge.** The item is saved first and its pages are charged after that, so you never pay for a result that was not saved.

### Input

| Field | Default | What it does |
|---|---|---|
| `urls` | (required) | Direct links to PDF or image files, up to 1,000 per run. Exact duplicates are read once. |
| `languages` | `["eng"]` | OCR languages, up to 5: eng, deu, fra, spa, ita, por, nld, pol, ces, ukr, rus, bul, ron, hun, swe, dan, nor, fin, tur. Used on every OCR'd page, in Auto and Always mode. |
| `ocrMode` | `auto` | `auto`: text layer first, OCR where needed. `always`: OCR every page. `never`: text layer only (images then fail). |
| `pageRange` | all pages | e.g. `1-3,7,10-` (1-based), applied to every document. For a multi-page TIFF it selects frames. |
| `maxPagesPerDocument` | `0` (no cap) | Stop after this many pages of each document. |
| `includePages` | `false` | Adds the per-page `pages` list. |
| `removeHeadersFooters` | `true` | Drops short blocks (up to 100 characters) at the top or bottom of a page that repeat, digits ignored, on at least max(3, half) of the pages with text. |
| `autoRotate` | `true` | Detects and fixes pages turned by 90°, 180° or 270° before OCR. |
| `ocrDpi` | `300` | Render resolution for OCR of PDF pages, 150–400. |
| `maxFileSizeMb` | `100` | Larger files get status `error` and are not charged; up to 500. |
| `pdfPassword` | empty | Password for encrypted PDFs (tried for every PDF in the run). |

**Notes on input:** Images have no text layer, so `never` gives them status `error`. A single image counts as page 1, so a `pageRange` that leaves out page 1 gives that image an `error` too. Multi-page TIFFs use the range as frames. For a GIF, only the first frame is read. Exact duplicates are merged before the run starts: the file is read and charged once and gets one item.

Minimal input:

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ]
}
```

### Output

The two items below come from a real run of the default input on Apify (2026-11-18, build 0.1.13; later builds changed only this README). The W-9 `markdown` and `text` are shortened ("…"); the second item is complete.

```json
[
  {"url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf", "finalUrl": null, "status": "ok", "error": null,
   "fileName": "fw9.pdf", "fileType": "pdf", "fileSizeBytes": 140815, "pageCount": 6, "pagesProcessed": 6,
   "pagesTextLayer": 6, "pagesOcr": 0, "pagesEmpty": 0, "pagesFailed": 0, "ocrLanguages": [],
   "ocrConfidence": null, "title": "Form W-9 (Rev. March 2024)", "author": "SE:W:CAR:MP",
   "createdAt": "2024-03-06T08:18:13-05:00",
   "markdown": "Form W-9\n\n(Rev. March 2024)\nDepartment of the Treasury\nInternal Revenue Service\nBefore you begin. For guidance related to the purpose of Form W-9, see Purpose of Form, below.\n\n# Request for Taxpayer Identification Number and Certification\n\n…",
   "text": "Form W-9\n\n(Rev. March 2024)\n…", "charCount": 37700, "wordCount": 6230, "truncated": false,
   "fullMarkdownUrl": null, "fullTextUrl": null, "note": null, "durationSec": 1.35,
   "processedAt": "2026-11-18T13:07:35Z"},
  {"url": "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif", "finalUrl": null,
   "status": "ok", "error": null, "fileName": "phototest.tif", "fileType": "tiff", "fileSizeBytes": 38668,
   "pageCount": 1, "pagesProcessed": 1, "pagesTextLayer": 0, "pagesOcr": 1, "pagesEmpty": 0, "pagesFailed": 0,
   "ocrLanguages": ["eng"], "ocrConfidence": 95.5, "title": null, "author": null, "createdAt": null,
   "markdown": "This is a lot of 12 point text to test the ocr code and see if it works on all types of file format.\n\nThe quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox.\n",
   "text": "This is a lot of 12 point text to test the ocr code and see if it works on all types of file format.\n\nThe quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox. The quick brown dog jumped over the lazy fox.\n",
   "charCount": 286, "wordCount": 60, "truncated": false, "fullMarkdownUrl": null, "fullTextUrl": null,
   "note": null, "durationSec": 0.47, "processedAt": "2026-11-18T13:07:36Z"}
]
```

| Field | Type | Meaning |
|---|---|---|
| `url` | string | The URL from your input. |
| `finalUrl` | string or null | Where the file was downloaded from after share-link conversion and redirects; null if the same as `url`, or if the file could not be downloaded or opened. |
| `status` | string | `ok`, `partial`, `error` or `skipped` (see below). |
| `error` | string or null | Plain-English reason for `error`, `skipped` or `partial`. |
| `fileName`, `fileType`, `fileSizeBytes` | string, string, integer | Name sent by the host (Content-Disposition), else from the URL path; type detected from the content (`pdf`, `png`, `jpeg`, `tiff`, `webp`, `bmp`, `gif`); downloaded size. For a file that could not be downloaded or opened, `fileName` comes from the URL path (e.g. `view` for a failed Drive link) and the type and size are null. |
| `pageCount` | integer | Pages in the PDF or frames in the TIFF (1 for other images; 0 if the file was not read). |
| `pagesProcessed` | integer | Pages with a result, after `pageRange` and `maxPagesPerDocument`. |
| `pagesTextLayer` | integer | Pages read from the text layer (charged as `page`). |
| `pagesOcr` | integer | Pages or images read with OCR (charged as `ocr-page`). |
| `pagesEmpty`, `pagesFailed` | integer | Blank pages and failed pages (both free). |
| `ocrLanguages` | array | OCR languages used; empty when nothing was OCR'd. |
| `ocrConfidence` | number or null | Mean Tesseract word confidence, 0–100, over the OCR'd pages. |
| `title`, `author`, `createdAt` | string or null | From the PDF metadata. `createdAt` is ISO 8601 with the PDF's time zone (e.g. `-05:00`, or `Z` for UTC); without a zone in the PDF it has no suffix. |
| `markdown`, `text` | string | The document as Markdown and as plain text. |
| `charCount`, `wordCount` | integer | Size of the full plain text. |
| `truncated`, `fullMarkdownUrl`, `fullTextUrl` | boolean, string or null | For very large documents (see below). |
| `note` | string or null | Extra information, e.g. that the per-page list was left out. |
| `pages` | array | Only with `includePages`: `page` (number), `method` (`text`, `ocr`, `empty` or `error`), `ocrConfidence` (0–100 or null), `text`, `error`. |
| `durationSec`, `processedAt` | number, string | Seconds spent on the file; when the item was saved (UTC). |

- **`status`:**
  - `ok`: every selected page was read or was blank;
  - `partial`: some pages failed, or the charge limit or the run timeout stopped the file midway (`error` says which);
  - `error`: the file could not be read, e.g. HTTP 404, too large, damaged, wrong password;
  - `skipped`: not read because the charge limit was reached or the run was close to its timeout. Files the run had no time to start get a `skipped` item too. Skipped files are free.
- **Every item has the same fields.** If a file was not downloaded or not opened (an HTTP error, the size limit, a damaged or locked file, an unsupported type, a page range that selects no pages, or a file the run did not start), the page counts are 0, `markdown` and `text` are empty, and `fileType`, `fileSizeBytes`, `title` and the other file details are null. A file that was opened but stopped by the charge limit or the run timeout before its first page, or whose pages all failed, keeps its `fileType`, `pageCount` and metadata. `pages` is present only with `includePages` and only for files that were opened.
- **Very large documents:** if an item would be larger than about 8 MB, `markdown` and `text` keep the first 100,000 characters, `truncated` is `true`, and `fullMarkdownUrl` and `fullTextUrl` link the full files in the run's key-value store. The `pages` list is then left out.
- **Files follow Apify data retention;** copy them if you need permanent links.
- **Output tabs:** "Documents" shows status, page counts, confidence and the Markdown; "Markdown and text" shows both texts; "Run summary" is the `OUTPUT` record.

### Pricing

| Event | Price |
|---|---|
| `page`: a page read from the PDF text layer | $0.001 |
| `ocr-page`: a page or image read with OCR | $0.005 |

**Paid Apify plans pay less.** Apify Store discounts apply automatically: Bronze 10% off, Silver 20% off, Gold and higher 30% off. The prices above are Free-plan prices; the Store card shows the lowest (Gold) price. The start event (`apify-actor-start`) has no discount.

- **Free:** blank pages, failed pages, files with status `error` or `skipped`, and dataset items.
- **Apify start event:** `apify-actor-start` costs $0.00005 per GB of run memory, i.e. $0.0001 per run at the default 2 GB.
- **Examples:**
  - 1,000 text-layer pages: 1,000 × $0.001 = **$1.00**;
  - 1,000 scanned pages: 1,000 × $0.005 = **$5.00**;
  - a 40-page digital PDF: **$0.04** when every page has a usable text layer. A page that is mostly a picture (images on at least 30 % of the page and fewer than 200 characters of text) is OCR'd at $0.005; with 2 such pages the file costs 38 × $0.001 + 2 × $0.005 = **$0.048**.
- **Charge limit:** set "Maximum cost per run" in the run options. The Actor reserves each page's price before reading it, so it stops before going over: the file in progress becomes `partial` (or `skipped` if none of its pages was read yet) and the remaining files `skipped`.

### Limits

- **Per run:** up to 1,000 URLs and 5 OCR languages.
- **File size:** 100 MB by default (`maxFileSizeMb`), up to 500 MB.
- **Image size:** the decode limit depends on memory and color mode. At 2 GB it is about 200 megapixels for grayscale, 160 for RGB and 120 for other modes (RGBA, CMYK, palette); larger images get status `error`. Before OCR, images and rendered PDF pages above 40 megapixels are scaled down to 40.
- **Time per page:** 60 s to read a page's text layer (after that, Auto mode OCRs the page) and 180 s per OCR pass.
- **Run timeout:** the Actor stops 90 s before the timeout (20 % of the timeout for short runs), saves what is done, and lists the files it could not start as `skipped`. Raise the timeout or split the list for large jobs.
- **Speed, measured on Apify (2026-11-18):**
  - a dense two-column scanned page (about 4,700 characters): about 12 s at the default 2 GB and about 3 s at 8 GB (4 pages: 47 s and 12 s);
  - a 6-page digital PDF (IRS Form W-9): 1.3 s at 2 GB;
  - on that test scan this means about 300 scanned pages per hour at 2 GB and about 1,200 at 8 GB, in one run. Other scans can be slower or faster.
  - Your price per page is the same at any memory; only the start event grows ($0.0004 at 8 GB). So choose 8 GB for large scans.
- **Memory and CPU:** Apify gives more CPU to runs with more memory. Pages are OCR'd one at a time up to 8 GB, and two at a time from 16 GB.
- **Not supported:** handwriting, math formulas, complex charts, and tables in scans (they come out as plain text).

### Use it from your stack

You need no third-party API keys, only an Apify account and its API token.

- **API (curl):**
  ```bash
  curl -X POST "https://api.apify.com/v2/acts/klarto~pdf-ocr-markdown/run-sync-get-dataset-items" \
    -H "Authorization: Bearer YOUR_APIFY_TOKEN" -H "Content-Type: application/json" \
    -d '{"urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"]}'
  ```
  This call waits at most 300 s; a longer run returns HTTP 408. For big jobs, start the run and read the dataset when it has finished:
  ```bash
  curl -X POST "https://api.apify.com/v2/acts/klarto~pdf-ocr-markdown/runs" \
    -H "Authorization: Bearer YOUR_APIFY_TOKEN" -H "Content-Type: application/json" \
    -d '{"urls": ["https://example.com/scan-1.pdf", "https://example.com/scan-2.pdf"]}'
  # the response has data.id (the run ID); wait until data.status is SUCCEEDED or FAILED
  # (each file's row has status and error; FAILED only for invalid input or a run timeout too short for any file):
  curl "https://api.apify.com/v2/actor-runs/RUN_ID?waitForFinish=60" -H "Authorization: Bearer YOUR_APIFY_TOKEN"
  curl "https://api.apify.com/v2/actor-runs/RUN_ID/dataset/items?format=json" -H "Authorization: Bearer YOUR_APIFY_TOKEN"
  ```
- **Python** (`pip install apify-client`, version 3):
  ```python
  from apify_client import ApifyClient
  client = ApifyClient("YOUR_APIFY_TOKEN")
  run = client.actor("klarto/pdf-ocr-markdown").call(run_input={"urls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"]})
  print(client.dataset(run.default_dataset_id).list_items().items[0]["markdown"])
  ```
- **n8n:** the Apify node → Run an Actor → `klarto/pdf-ocr-markdown`, then read the dataset items.
- **Make and Zapier:** the Apify app → Run an Actor, with `klarto/pdf-ocr-markdown`.
- **MCP / AI agents:** `https://mcp.apify.com?tools=klarto/pdf-ocr-markdown`. The Actor takes an array of URLs and returns Markdown, and every item has `status` and `error`, so an agent can see which files failed and why.

### FAQ

**How do I get a direct link from Dropbox or Google Drive?**
Paste the share link as it is. A Dropbox link (`https://www.dropbox.com/...?dl=0`) is changed to `dl=1`, which Dropbox serves as a download. A Google Drive file link (`https://drive.google.com/file/d/<FILE_ID>/view`) is changed to `https://drive.google.com/uc?export=download&id=<FILE_ID>`. The Drive file must be shared as "Anyone with the link". Google Docs documents and Drive files too large for a direct download return a web page, and the item gets an `error` that says so; use another direct link then.

**Does it read tables?**
Yes, from digital PDFs: tables drawn with ruled lines become Markdown tables. Tables without lines and tables in scans come out as plain text.

**Why was my digital PDF charged as OCR pages?**
In Auto mode a page is OCR'd ($0.005) when its text layer cannot be used: it is missing, has fewer than 20 characters, has more than 10 % of glyphs that do not map to letters, could not be read within 60 s, or the page is mostly a picture (images on at least 30 % of the page and fewer than 200 characters of text). `pages[].method` shows which pages were OCR'd. Choose `never` to read only the text layer.

**My scanned PDF was charged as text pages. Why?**
Many scans already contain an OCR text layer, e.g. from the scanner software or archive.org. Auto mode reads that layer ($0.001 per page). Choose `always` if that layer is poor and you want Tesseract to read the page images.

**How accurate is it?**
It depends on the scan. In our runs the mean word confidence (`ocrConfidence`) was 95.5 on the Tesseract test page above and 94.5 on a 1965 two-column scan. Check `ocrConfidence` per file, or per page with `includePages`: low values point to poor scans, and 400 DPI can help with tiny print.

**Can it read password-protected PDFs?**
Yes, with `pdfPassword`. Without the right password the file gets status `error` and is free.

**Is my data private?**
Files are downloaded to the run's temporary disk, read, and deleted after each file. Results stay in your own Apify dataset and key-value store. Only public addresses are fetched; private and internal network addresses are refused.

**Do I pay for files that fail?**
No. Files with status `error` or `skipped`, failed pages and blank pages are not charged.

### Fair use and licences

- Process only files you own or have the right to process.
- Open-source parts: Tesseract OCR and its language data (Apache-2.0, Debian packages), pytesseract (Apache-2.0), pdfplumber (MIT), pdfminer.six (MIT), pypdfium2 (Apache-2.0 or BSD-3-Clause) with PDFium (BSD-3-Clause), Pillow (MIT-CMU), httpx (BSD-3-Clause).

### Ready-made examples

Saved inputs for common jobs: open one and run it as it is, or change the input first.

- [Convert PDFs to Markdown for RAG and LLMs](https://apify.com/klarto/pdf-ocr-markdown/examples/pdf-to-markdown-for-rag)
- [Extract text from scanned images with OCR](https://apify.com/klarto/pdf-ocr-markdown/examples/image-ocr-to-text)
- [OCR every page of PDFs with a broken text layer](https://apify.com/klarto/pdf-ocr-markdown/examples/force-ocr-pdf-pages)
- [OCR German, French and Italian text from scans](https://apify.com/klarto/pdf-ocr-markdown/examples/ocr-multilingual-scans-to-text)
- [Extract text from PDF files (PDF to text)](https://apify.com/klarto/pdf-ocr-markdown/examples/extract-text-from-pdf)

### Related Actors

- [Image Upscaler 2x / 4x](https://apify.com/klarto/image-upscaler-cpu): sharpen low-resolution scans before OCR.
- [Audio & Video Transcription to Text, SRT and VTT](https://apify.com/klarto/audio-video-transcription): the same text output for recordings.
- [Website Screenshot & HTML to Image / PDF](https://apify.com/klarto/website-screenshot-pdf): turn web pages into PDFs or images.
- [Website SEO Audit & Broken Link Checker](https://apify.com/klarto/website-seo-audit): audit your own site.

### Support

Open an issue on the Actor page. We aim to answer within a week.

# Actor input Schema

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

Direct links to PDF or image files (PNG, JPEG, TIFF, WEBP, BMP, GIF), one per line, up to 1,000 per run; duplicates are read once. Public links only. Dropbox share links and Google Drive file links shared as 'anyone with the link' are converted to direct downloads. Only use files you have the right to process.

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

Languages of the text to OCR (up to 5). Used on every page that is OCR'd: scanned pages in Auto mode and all pages in Always mode. Not used for pages read from a PDF text layer. Pick only the languages that appear: each extra language makes OCR slower.

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

Auto reads the PDF text layer and runs OCR only on scanned or broken pages. Always OCRs every page (use it when a PDF's text layer is wrong). Never reads only the text layer (cheapest); images then fail with an error, because they have no text layer.

## `pageRange` (type: `string`):

Pages to read from every document, e.g. 1-3,7,10- (1-based). Empty = all pages. For multi-page TIFF images this selects frames; a single image is page 1, so a range without page 1 gives that image an error.

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

Stop after this many pages of each document (after the page selection). 0 = no limit.

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

Adds a 'pages' list with each page's number, text, method (text, ocr, empty or error) and OCR confidence (0-100). Useful for citations and RAG chunking.

## `removeHeadersFooters` (type: `boolean`):

Drops short blocks (up to 100 characters) at the top or bottom of a page that repeat, digits ignored, on at least max(3, half) of the pages with text: page numbers and running titles. Needs 3 or more pages with text. A page is never emptied.

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

Detects pages and photos that are turned 90 or 180 degrees and rotates them before OCR.

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

Resolution used to render PDF pages for OCR. 300 suits most documents; 400 helps tiny print; 200 is faster.

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

Files larger than this get status 'error' and are not charged (1-500 MB).

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

Password for encrypted PDFs (the same password is tried for every PDF in the run). Leave empty otherwise.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "languages": [
    "eng"
  ],
  "ocrMode": "auto",
  "maxPagesPerDocument": 0,
  "includePages": false,
  "removeHeadersFooters": true,
  "autoRotate": true,
  "ocrDpi": 300,
  "maxFileSizeMb": 100
}
```

# Actor output Schema

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

One record per file: status, page counts, OCR confidence, the Markdown and any error. The full record (plain text, metadata, per-page list) is in the dataset.

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

The Markdown and plain text of each file.

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

Files ok, partial, failed and skipped; text-layer and OCR page totals; failure reasons.

# 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://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("klarto/pdf-ocr-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 = { "urls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("klarto/pdf-ocr-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 '{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ]
}' |
apify call klarto/pdf-ocr-markdown --silent --output-dataset

```

## MCP server setup

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