# PDF to LLM Markdown — RAG Chunks & OCR-Ready (`plugiverse/pdf-to-llm-markdown`) Actor

Convert PDF URLs into clean LLM-ready Markdown with page markers and RAG PDF chunks. Built for agents and Apify MCP. Text-layer pages from $0.0002; OCR PDF markdown only when needed. No HTML crawling. LIMITED_PERMISSIONS + pay-per-event for agentic payments.

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

## Pricing

from $5.00 / 1,000 pdf 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 LLM Markdown — RAG Chunks & OCR-Ready

**Store:** https://apify.com/plugiverse/pdf-to-llm-markdown\
**Actor id:** `o8HXWdpdrS10NmQMW` · username `plugiverse` · **LIMITED_PERMISSIONS** · **pay-per-event**

Turn **PDF URLs** into clean, LLM-ready **Markdown** with optional **RAG chunks** and page markers. Text-layer pages are cheap; OCR is charged only for pages that need it. **No HTML crawling, no DOCX/XLSX.**

### 🤖 Agents & Apify MCP (start here)

Agents discover this Actor through Apify MCP (`https://mcp.apify.com`) — search tools for **`pdf llm markdown`**, **`pdf to markdown`**, **`RAG PDF chunks`**, or **`OCR PDF markdown`**.

Minimal call:

```json
{
  "pdfUrls": ["https://raw.githubusercontent.com/mozilla/pdf.js/ba2edeae/web/compressed.tracemonkey-pldi-09.pdf"],
  "enableOcr": "never",
  "maxPages": 3,
  "chunkSize": 2000,
  "includePageMarkers": true
}
```

What you get back (one dataset row per URL):

- `status`: `"ok"` or `"error"`
- `markdown`: full text with `<!-- page: N -->` markers
- `chunks[]`: `{ index, text, pageStart, pageEnd, charCount }` for RAG citations
- `billing.eventsCharged`: what was billed

Failed PDFs are **free** (`status: "error"`, machine-readable `error.code`). A run never “succeeds while empty” when `failOnAllErrors` is true (default).

Eligible for agentic / PPE agent runs: LIMITED_PERMISSIONS + pay-per-event (no usage addon, no Standby).

### What it does / when to use it

Use it when an agent or RAG pipeline already has PDF links (filings, manuals, papers) and needs Markdown plus citation-friendly chunks.\
Don’t use it to crawl websites, convert Office docs, or unlock paywalled / password-protected PDFs (v1).

### Input

| Field | Type | Default | Notes |
|---|---|---|---|
| `pdfUrls` | string\[] | required | http(s) PDF URLs; up to 100; duplicates removed |
| `maxPages` | int 1–500 | 100 | Cap pages processed per PDF |
| `chunkSize` | int | 2000 | RAG chunk target size in characters; `0` disables chunks |
| `enableOcr` | `never` | `auto` | `always` | `auto` | OCR empty text-layer pages. OCR still stubbed → `OCR_NOT_IMPLEMENTED` on scans; text PDFs work. |
| `includePageMarkers` | bool | true | Insert `<!-- page: N -->` before each page |
| `maxPdfMb` | int 1–100 | 50 | Download size cap |
| `failOnAllErrors` | bool | true | Run ends FAILED if every PDF fails |

### Output (one row per URL)

```json
{
  "sourceUrl": "https://example.com/report.pdf",
  "status": "ok",
  "error": null,
  "pageCount": 12,
  "pagesProcessed": 12,
  "markdown": "<!-- page: 1 -->\n# Report\n…",
  "chunks": [{"index": 0, "text": "…", "pageStart": 1, "pageEnd": 2, "charCount": 1840}],
  "ocrUsed": false,
  "billing": {"eventsCharged": [{"event": "pdf-start", "count": 1}, {"event": "text-page", "count": 12}]},
  "fetchedAt": "2026-11-06T07:00:00Z"
}
```

#### Error codes (all free)

`INPUT_INVALID`, `DOWNLOAD_FAILED`, `NOT_PDF`, `EMPTY_PDF`, `OCR_NOT_IMPLEMENTED`, `PDF_CORRUPT`, `TIMEOUT`, `TOO_LARGE`, `INTERNAL_ERROR` (retryable), `CHARGE_LIMIT_REACHED`.

### Pricing (pay per event)

| Event | Price | When |
|---|---|---|
| `apify-actor-start` | $0.00005 | Synthetic start (Apify covers first 5s compute) |
| `pdf-start` | $0.005 | PDF converted successfully (`status: ok`) |
| `text-page` | $0.0002 | Per page with a usable text layer |
| `ocr-page` | $0.008 | Per page that required OCR |

Error rows: $0. Example: a **20-page text PDF** ≈ $0.005 + 20×$0.0002 = **~$0.009**.

### Scope lock (v1)

- PDF URLs only (http/https). Magic-byte `%PDF` check after download.
- PyMuPDF text-layer extraction.
- OCR stubbed until wired; use `enableOcr: "never"` for text-layer PDFs.
- No website crawl, no DOCX/XLSX, no password unlock beyond empty-password try.

### Kill rule

Kill / unpublish if **<20 external users** or **<$20 revenue by day 45** after Store publish.

### Changelog

- 0.1.3: Agent README example matches input schema (`chunkSize`); MCP search keywords expanded.
- 0.1.2: Store public + output schema; agent README; AUTOMATION category; `apify-actor-start`.
- 0.1.0: text-layer convert, RAG chunks, PPE events, OCR stubbed.

# Actor input Schema

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

http(s) URLs of PDF files. Prefer links ending in .pdf; URLs without .pdf are accepted when the response is application/pdf (checked via Content-Type and %PDF magic). No HTML page crawling. Max 100 per run. Invalid entries come back as free rows with error.code INPUT_INVALID.

## `maxPages` (type: `integer`):

Stop after this many pages (1-500). Useful to cap cost on huge manuals.

## `chunkSize` (type: `integer`):

Target size for RAG chunks. 0 disables chunks (markdown only). Minimum 200 when enabled. Chunks include pageStart/pageEnd for citations.

## `enableOcr` (type: `string`):

never = text layer only (cheapest). auto = OCR pages whose text layer is empty (recommended). always = same as auto for empty pages; text-layer pages stay cheap. OCR is stubbed in the local draft and returns OCR_NOT_IMPLEMENTED until enabled on the Apify image; text-layer PDFs work fully.

## `includePageMarkers` (type: `boolean`):

Insert HTML comments before each page so LLMs and chunkers can cite page numbers.

## `maxPdfMb` (type: `integer`):

Reject downloads larger than this. Hard cap 100 MB.

## `failOnAllErrors` (type: `boolean`):

If true, a run where no PDF succeeds ends FAILED with an error summary instead of an empty SUCCEEDED run.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://pdfobject.com/pdf/sample.pdf"
  ],
  "maxPages": 100,
  "chunkSize": 2000,
  "enableOcr": "auto",
  "includePageMarkers": true,
  "maxPdfMb": 50,
  "failOnAllErrors": true
}
```

# Actor output Schema

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

Dataset items: sourceUrl, status, markdown, chunks, page counts, ocrUsed, billing, errors.

# 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://pdfobject.com/pdf/sample.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("plugiverse/pdf-to-llm-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://pdfobject.com/pdf/sample.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("plugiverse/pdf-to-llm-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://pdfobject.com/pdf/sample.pdf"
  ]
}' |
apify call plugiverse/pdf-to-llm-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plugiverse/pdf-to-llm-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/o8HXWdpdrS10NmQMW/builds/4fOUdKfYa31nqIoh9/openapi.json
