# PDF to Markdown & Text Extractor with OCR (`signalloom/pdf-text-extractor`) Actor

Convert PDFs to text and Markdown for AI, RAG and search. Reads the text layer, runs OCR only on scanned pages, keeps headings and two-column reading order, strips repeated headers and footers. PNG/JPG images too. No start fee: pay per document and per page.

- **URL**: https://apify.com/signalloom/pdf-text-extractor.md
- **Developed by:** [Signalloom](https://apify.com/signalloom) (community)
- **Categories:** Developer tools, AI, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 document extracteds

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 Extractor with OCR

Turn **PDFs and scanned documents into clean Markdown, plain text and JSON**, ready for AI agents, RAG pipelines, search indexes and spreadsheets. Give it links; get back one row per document.

- **Reads the PDF's own text layer first:** fast, exact, cheap.
- **OCR only where it's needed:** pages with no text (scans, photos, faxes) go through Tesseract OCR automatically. You pay for OCR only on those pages.
- **Readable Markdown, not a text dump:** headings from font sizes, paragraphs re-joined, hyphenated words fixed, bullet and numbered lists kept, **two-column pages read column by column**, repeated headers, footers and page numbers removed.
- **Page markers** (`<!-- page 3 -->`) and a per-page array, so you can cite the page an answer came from.
- **Images too:** PNG, JPEG, WebP and TIFF files are OCR'd.
- **No start fee.** A 6-page PDF with a text layer finishes in under 5 seconds.

### Use this when…

- you need **PDF to Markdown** or **PDF to text** for an LLM, a RAG knowledge base or a vector database
- you have **scanned PDFs** or document photos and need the text (**OCR**) without setting up Tesseract yourself
- you process **reports, filings, contracts, manuals, invoices or research papers** in bulk from links
- you want **clean text from two-column PDFs** (papers, government forms, brochures) in reading order
- an **AI agent** needs to read a PDF from a URL

### For AI agents

- **Run** `signalloom/pdf-text-extractor` (Apify MCP server `call-actor`, or the Apify API) with input like `{"documentUrls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf"]}`.
- **Returns** one dataset row per document: `markdown` (whole document, with `<!-- page N -->` markers), `text`, `pageCount`, `ocrPages`, `wordCount`, `title`, `author`, and a `pages` array (`page`, `method`, `markdown`).
- **Typical cost:** $0.003 per document + $0.0001 per text page; scanned pages are $0.006 per OCR page instead. A 6-page text PDF costs $0.0036; errors and blank pages are free.

### How to use it

1. Paste **Document links**, one per line: public PDF or image links, or links to files in your Apify key-value store.
2. **OCR**: leave on **Auto** (OCR only pages without text). **Off** is cheapest; **Always** re-reads every page with OCR when a PDF's text layer is broken.
3. Pick **OCR languages** if the scans aren't English (Spanish, French, German, Portuguese, Italian).
4. Optional: **Max pages per document** (e.g. 20 to read only the start of long reports), **Max file size**.
5. Click **Start**.

### Output

A real record from a run on 2026-11-24 (the prefilled IRS Form W-9), with long text shortened:

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileName": "fw9.pdf",
  "fileType": "pdf",
  "status": "ok",
  "pageCount": 6,
  "pagesProcessed": 6,
  "textLayerPages": 6,
  "ocrPages": 0,
  "wordCount": 6361,
  "title": "Form W-9 (Rev. March 2024)",
  "subject": "Request for Taxpayer Identification Number and Certification",
  "created": "2024-03-06T13:18:13.000Z",
  "markdown": "… <!-- page 3 -->\n\nCertain payees and payments are exempt from backup withholding. See Exempt payee code, later, and the separate Instructions for the Requester of Form W-9 for more information. …\n\n## What Is FATCA Reporting?\n\nThe Foreign Account Tax Compliance Act (FATCA) requires a participating foreign financial institution to report all …",
  "pages": [
    { "page": 3, "method": "text", "chars": 6342, "confidence": null, "markdown": "Certain payees and payments are exempt from backup withholding. …" }
  ]
}
```

Page 3 of that form is printed in two columns; the Markdown reads the left column, then the right, and the running header "Form W-9 (Rev. 3-2024) Page 3" is removed.

#### Fields

| Field | Meaning |
|---|---|
| `status`, `error` | `ok` or `error` with the reason (not a PDF, too large, blocked by robots.txt, HTTP error). Errors are not charged. |
| `pageCount`, `pagesProcessed`, `truncated` | Pages in the file, pages read, and whether **Max pages** cut it short |
| `textLayerPages`, `ocrPages`, `emptyPages` | How each page was read |
| `ocrMeanConfidence` | Tesseract's average confidence (0–100) over OCR pages |
| `wordCount`, `charCount` | Size of the extracted text |
| `title`, `author`, `subject`, `keywords`, `creator`, `producer`, `created`, `modified`, `pdfVersion` | PDF metadata, when present |
| `markdown`, `text` | The whole document |
| `pages` | Per page: `page`, `method` (`text`, `ocr` or `empty`), `chars`, `confidence`, `markdown` |
| `markdownUrl`, `textUrl` | Only for very large documents: the full text in the key-value store (the row keeps the first 200,000 characters) |

The run summary (`OUTPUT`) lists each document's status, pages, OCR pages and time.

### Pricing

Pay per result, no start fee:

| Event | Price | Charged for |
|---|---|---|
| Document | $0.003 | each PDF or image turned into Markdown and text |
| Text page | $0.0001 | each page read from the PDF's own text layer |
| OCR page | $0.006 | each scanned page or image read with OCR |

Failed downloads, robots.txt blocks, non-PDF files and blank pages are free.

Examples:

- **IRS Form W-9** (6 text pages): $0.003 + 6 × $0.0001 = **$0.0036**, about 4 seconds.
- **IRS Publication 15** (59 text pages): $0.003 + 59 × $0.0001 = **$0.0089**, about 6 seconds.
- **A 10-page scanned document:** $0.003 + 10 × $0.006 = **$0.063**, about 10–15 seconds per page.

If you set a **maximum cost per run**, the Actor checks before each document that the document and its pages fit in what's left. It reads fewer pages, or stops, rather than charging for a document you don't receive.

### Good to know

- **OCR speed:** about 10–15 seconds per dense scanned page. Text-layer pages take milliseconds.
- **Tables** come out as text lines in reading order, not as Markdown tables.
- **Forms and complex layouts** (boxes, sidebars, mixed columns) are read as well as the layout allows; check the `pages` array for page-level results.
- **Password-protected PDFs** aren't supported yet.
- **Polite downloading:** files are fetched with a clear client name, robots.txt is respected (a disallowed file is skipped with a clear error), and files over the size limit are skipped.

### Feedback

Want another format (Word, HTML) or Markdown tables? Open an issue on the **Issues** tab.

# Actor input Schema

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

Links to PDF files or images (PNG, JPEG, WebP, TIFF), one per line. Public links, or links to files in your Apify key-value store. Up to 500 per run. Example: "https://www.irs.gov/pub/irs-pdf/fw9.pdf".

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

auto (default): read the PDF's text layer and run OCR only on pages that have no text (scans, photos). off: never OCR (fastest, cheapest; scanned pages come back empty). always: OCR every page, even if it has a text layer (for PDFs whose text layer is broken).

## `ocrLanguages` (type: `array`):

Languages of the scanned text. Default English. Choose more than one for mixed documents (slower).

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

Read at most this many pages of each document (from the start). Example: 20 to read only the beginning of long reports.

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

On (default): each result also has a pages array with every page's Markdown, how it was read (text layer or OCR) and the OCR confidence.

## `pageBreakMarkers` (type: `boolean`):

On (default): the full Markdown has  comments between pages, handy for citations in RAG. Off: one continuous text.

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

Skip files larger than this. Default 50 MB.

## Actor input object example

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPagesPerDocument": 100,
  "includePages": true,
  "pageBreakMarkers": true,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

## `results` (type: `string`):

No description

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

// Run the Actor and wait for it to finish
const run = await client.actor("signalloom/pdf-text-extractor").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"],
    "maxPagesPerDocument": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("signalloom/pdf-text-extractor").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"
  ],
  "maxPagesPerDocument": 100
}' |
apify call signalloom/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,signalloom/pdf-text-extractor"
        }
    }
}
```

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/BCU7Ghe5PDGTOdX3Q/builds/JwryJbH0rllZKq0YG/openapi.json
