# PDF to Markdown & Text – Tables and OCR (`oldjard/pdf-to-markdown-text-ocr`) Actor

Turn PDF URLs into clean Markdown and plain text. Tables come out as real Markdown tables (and as rows), two- and three-column pages are read in order, and scanned pages are read with OCR. $2.50 per 1,000 PDFs.

- **URL**: https://apify.com/oldjard/pdf-to-markdown-text-ocr.md
- **Developed by:** [Joshua White](https://apify.com/oldjard) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.50 / 1,000 pdf reads

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 to Markdown & Text – Tables and OCR

Turn PDF links into **Markdown** and **plain text**. Tables come out as real **Markdown tables**, and also as rows you
can load into a spreadsheet. Two- and three-column pages (papers, newsletters, government reports) are read column by
column, in order. Scanned pages are read with **OCR**.

**Try it:** the input is prefilled with two PDFs: a research paper and a Federal Reserve statistical release. Click
Start and the results show in a few seconds.

### How to convert PDFs to Markdown

1. Paste PDF links, one per line. Each link must download the PDF file itself.
2. Leave **OCR for scanned pages** on `auto`.
3. Click **Start**, then download the results as JSON, CSV or Excel, or read them through the API.

### What you get for each PDF

| Field | What it is |
|---|---|
| `url`, `fileName` | The link you gave and the file name. `finalUrl` is set when the link redirected. |
| `status` | `ok` or `error`. |
| `markdown` | The whole document as Markdown. Each page starts with `<!-- page N -->`. Tables are Markdown tables. |
| `text` | The same content as plain text. Table rows are tab-separated lines. |
| `tables` | Every table as `{ page, rows }`, where `rows` is a list of rows and each row a list of cell texts. The first row is the header. |
| `pages` | Optional (**Include each page separately**): each page's Markdown and how it was read, `text` or `ocr`. |
| `pageCount`, `pagesProcessed` | Pages in the PDF, and pages read. |
| `ocrPages`, `tableCount` | Pages read by OCR, and tables found. |
| `metadata` | Title, author, subject, keywords, creator, producer, created and modified dates, when the PDF has them. |
| `note`, `error` | Plain-English notes (pages skipped, OCR off), or why a PDF failed. |

Example of a table in `markdown`, from page 31 of Apple's 2023 10-K:

```
|  | September 30, 2023 | Years ended September 24, 2022 | September 25, 2021 |
|---|---|---|---|
| Net sales: |  |  |  |
| Products | 298,085 | 316,199 | 297,392 |
| Services | 85,200 | 78,129 | 68,425 |
| Total net sales | 383,285 | 394,328 | 365,817 |
```

### How tables are found

Most tables in reports and filings have no grid lines, so the actor doesn't rely on them. It looks for rows whose
values line up in columns, then builds the grid from where the values sit on the page. Row labels stay in the first
column, section labels ("Net sales:") become their own rows, wrapped labels are joined, and header lines above the
numbers become the header row.

We checked this against tables we typed out by hand from 8 pages (Apple and Tesla 10-Ks, a Federal Reserve H.8
release, BEA GDP and EIA energy tables, a Census income table, two research papers): **662 of 666 cells came out in
the right row and column**.

It works best on tables of numbers. Tables made mostly of text (a two-column list of terms and definitions, for
example) come out as paragraphs.

### OCR for scanned pages

With OCR on `auto`, a page goes to OCR when it has almost no text layer and is covered by an image, like a scan or a
photo. Other pages are read from the text layer, which is exact and fast. Set OCR to `always` when a PDF's text layer
is garbled. OCR uses Tesseract and supports English, German, French, Spanish, Italian, Portuguese and Dutch.

OCR quality depends on the scan. Clean scans of printed pages read well. Faint typewriter copies, handwriting and
stamps read poorly.

### How much does it cost?

- **$2.50 per 1,000 PDFs**, including each PDF's first 50 pages.
- **$0.05 per 1,000 pages** after the first 50 pages of a PDF.
- **$3 per 1,000 scanned pages** read by OCR. Pages with a text layer are never charged for OCR.

PDFs that fail to download or open are free. A 10-page report costs $0.0025. Apify's $5 monthly free credit covers
about 2,000 PDFs. The run's maximum cost caps what you spend: before each PDF, pages and OCR are limited to what the
remaining budget covers.

### Input example

```json
{
    "urls": [
        "https://arxiv.org/pdf/1706.03762",
        "https://www.federalreserve.gov/releases/h8/current/h8.pdf"
    ],
    "ocr": "auto",
    "ocrLanguage": "eng",
    "maxPagesPerPdf": 500,
    "includeTables": true,
    "includeText": true,
    "includePages": false
}
```

### Limits

- Links must be public and must download a PDF. Pages behind a login aren't supported.
- The actor honours each site's robots.txt and paces requests to the same site. Some sites refuse automated
  downloads; those PDFs come back with `status: error` and aren't charged.
- Files up to 100 MB by default (**Max file size**, up to 500 MB).
- Password-protected PDFs open when you give the password.
- Very large outputs (over about 8 MB of text in one PDF) are saved to the run's key-value store, and the row links to
  them (`markdownUrl`, `textUrl`).

### Use it from code

```bash
curl -X POST "https://api.apify.com/v2/acts/oldjard~pdf-to-markdown-text-ocr/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://arxiv.org/pdf/1706.03762"]}'
```

# Actor input Schema

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

Links to PDF files, one per line. Each link must download the PDF itself, not a web page about it.

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

auto: pages without a text layer (scans, photos) are read with OCR, other pages are read directly. off: never OCR; scanned pages come back empty. always: OCR every page, even ones with a text layer (use when the text layer is garbled).

## `ocrLanguage` (type: `string`):

The language of the scanned pages. Only used for OCR.

## `maxPagesPerPdf` (type: `integer`):

Pages past this are not read and not charged. The first 50 pages are included in the price of each PDF.

## `includeTables` (type: `boolean`):

Also return each table as a list of rows (arrays of cell text), with its page number. Tables are always in the Markdown either way.

## `includeText` (type: `boolean`):

Also return the document as plain text (tables as tab-separated lines).

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

Also return a list of pages with each page's Markdown and how it was read (text layer or OCR). Handy for chunking. The full Markdown always marks page starts with .

## `password` (type: `string`):

Optional. Used for password-protected PDFs.

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

Larger files are skipped and not charged.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://www.federalreserve.gov/releases/h8/current/h8.pdf"
  ],
  "ocr": "auto",
  "ocrLanguage": "eng",
  "maxPagesPerPdf": 500,
  "includeTables": true,
  "includeText": true,
  "includePages": false,
  "maxFileSizeMb": 100
}
```

# Actor output Schema

## `overview` (type: `string`):

No description

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

No description

## `summary` (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 = {
    "urls": [
        "https://arxiv.org/pdf/1706.03762",
        "https://www.federalreserve.gov/releases/h8/current/h8.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("oldjard/pdf-to-markdown-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 = { "urls": [
        "https://arxiv.org/pdf/1706.03762",
        "https://www.federalreserve.gov/releases/h8/current/h8.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("oldjard/pdf-to-markdown-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 '{
  "urls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://www.federalreserve.gov/releases/h8/current/h8.pdf"
  ]
}' |
apify call oldjard/pdf-to-markdown-text-ocr --silent --output-dataset

```

## MCP server setup

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