# PDF to Text & Markdown Converter (Tables + OCR Fallback) (`mrlarryjohnson/pdf-to-text-markdown`) Actor

Convert PDFs to clean text and Markdown in bulk: headings, bullet lists and tables as Markdown pipe tables, with automatic OCR for scanned pages (7 languages). Ideal for RAG/LLM pipelines, search indexing and data entry. Pay per page; failed files are free.

- **URL**: https://apify.com/mrlarryjohnson/pdf-to-text-markdown.md
- **Developed by:** [Larry Johnson](https://apify.com/mrlarryjohnson) (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 $1.00 / 1,000 pdf 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 to Text & Markdown Converter (Tables + OCR Fallback)

Turn PDFs into clean, LLM-ready **Markdown** and plain **text** in bulk. One row per PDF:

- **Headings** detected from font size (`#`, `##`), **bullet lists** normalized to `- `
- **Tables** converted to Markdown pipe tables (and tab-separated in the plain text)
- **Scanned pages** (no text layer) automatically **OCR'd** with Tesseract: English, Spanish, French, German, Portuguese, Italian, Dutch
- Optional **per-page output** and **page ranges** (`1-5, 8, 10-`)
- Page count, OCR page count, table count and the document title

### Use cases

- **RAG / AI pipelines:** feed reports, manuals and papers to an LLM or vector database as Markdown
- **Search indexing:** extract the text of your PDF library
- **Data entry:** pull tables out of invoices, price lists and statements
- **Archives:** make scanned documents searchable

### Input

| Field | Default | Notes |
|---|---|---|
| `pdfUrls` | — | Direct PDF links (public http/https), up to 1,000 per run, 60 MB each |
| `ocrFallback` | `true` | OCR pages that have no text layer |
| `ocrLanguage` | `eng` | eng, spa, fra, deu, por, ita, nld |
| `pageRange` | all | e.g. `1-3, 7` |
| `maxPagesPerPdf` | `300` | Safety cap per file |
| `includePages` | `false` | Adds a `pages` array |

### Output example

```json
{
  "url": "https://example.com/report.pdf", "fileName": "report.pdf", "title": "Annual Report",
  "pageCount": 12, "pagesProcessed": 12, "ocrPages": 0, "tableCount": 3,
  "markdown": "# Annual Report\n\n## Results\n- Revenue grew 12%\n\n| Region | Q1 | Q2 |\n|---|---|---|\n| EU | 10 | 12 |",
  "text": "Annual Report\nResults\n• Revenue grew 12%\nRegion\tQ1\tQ2\n...", "error": null
}
```

Multi-page documents have pages separated by `---` in `markdown`.

### Pricing (pay per event)

- **$1.00 per 1,000 pages** (`page-processed`, $0.001 per page, OCR included), plus the standard $0.00005 actor start.
- **Free:** files that fail to download, aren't PDFs, are password-protected or can't be parsed.
- Respects your run's maximum cost: pages beyond your limit are not processed.

### Notes

- Only process documents you have the right to use. Files are processed in memory and not stored by the Actor.
- Links must be public; private network and cloud metadata addresses are blocked.
- Password-protected PDFs return `PDF_ENCRYPTED`.

***

*Actively maintained. Issues answered within 24 hours on the Issues tab.*

# Actor input Schema

## `pdfUrls` (type: `array`):

Direct links to PDF files (public http/https). Up to 1,000 per run, 60 MB each.

## `ocrFallback` (type: `boolean`):

Pages with no text layer (scans, photos) are run through Tesseract OCR.

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

Language used for OCR pages.

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

Optional, e.g. "1-5, 8, 10-". Empty = all pages.

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

Safety cap on pages processed (and charged) per file.

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

Also return a `pages` array with text/Markdown for each page.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "ocrFallback": true,
  "ocrLanguage": "eng",
  "maxPagesPerPdf": 300,
  "includePages": false
}
```

# Actor output Schema

## `results` (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 = {
    "pdfUrls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mrlarryjohnson/pdf-to-text-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 = { "pdfUrls": ["https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("mrlarryjohnson/pdf-to-text-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 '{
  "pdfUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call mrlarryjohnson/pdf-to-text-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mrlarryjohnson/pdf-to-text-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/Uv2Y3dO3ZTguWqVXs/builds/83bpCAdBt2DYyAvqP/openapi.json
