# Pdf To Markdown (`vivid_astronaut/pdf-to-markdown`) Actor

- **URL**: https://apify.com/vivid\_astronaut/pdf-to-markdown.md
- **Developed by:** [BRAINIALL Team](https://apify.com/vivid_astronaut) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$5.00 / 1,000 page converted to markdowns

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF to Markdown with OCR (RAG-ready) — by Brainiall

Convert any PDF document (native or scanned) into **clean, structured Markdown** ready for RAG pipelines, LLMs, AI agents, vector databases and knowledge bases — in seconds.

Provide one or more PDF URLs and get back clean, chunk-friendly Markdown preserving headings, paragraphs, lists, tables, and document layout without clutter.

### What it does

- **Native PDF Parsing** — fast text, table and layout extraction from standard PDFs.
- **Automatic & Forced OCR** — embedded visual OCR engine extracts text seamlessly from scanned documents, forms, and image-based PDFs.
- **Page Range Selection** — specify exact page ranges (e.g. `1-5`, `3-10`) to process only what you need and optimize token usage.
- **RAG-ready Output** — outputs clean heading structures and word counts per document, perfectly formatted for semantic chunking and embedding.
- **Batch Processing** — process multiple PDF URLs concurrently with built-in retries and error isolation.

Powered by the **Brainiall PDF engine** ([api.brainiall.com](https://app.brainiall.com)) — high-performance document intelligence for production AI workloads.

### Who it's for

- **RAG & Vector DB Engineers** — ingest research papers, whitepapers, contracts, and technical manuals directly into Pinecone, Qdrant, Chroma, or Weaviate.
- **AI Agent Developers** — give your agents token-efficient, clean Markdown from complex PDF documents instead of messy raw text extractions.
- **Data & Compliance Teams** — digitize and structure legacy scanned archives into structured text.
- **LLM Fine-Tuners** — build high-quality Markdown datasets from domain-specific PDF libraries.

### Input

```json
{
    "startUrls": [
        { "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" },
        { "url": "https://example.com/scanned-contract.pdf" }
    ],
    "pageRange": "1-5",
    "useOcr": false
}
```

| Field | Description |
|-------|-------------|
| `startUrls` | List of HTTP/HTTPS URLs pointing to PDF documents. |
| `pageRange` | Optional range of pages to convert (e.g., `"1-5"`, `"1,3,5"`). Leave empty for all pages. |
| `useOcr` | `true` to force visual OCR processing. `false` uses native extraction with auto-OCR fallback for scanned pages. |

### Output

Each document produces a structured dataset item:

```json
{
    "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "status": "SUCCESS",
    "markdown": "# Dummy PDF Header\n\nThis is a sample PDF document converted into clean Markdown...",
    "pages": 1,
    "word_count": 42,
    "ocr_used": false,
    "page_range": "1-5",
    "error": null
}
```

If a document URL is unreachable or invalid, an item with `status: "ERROR"` and details is pushed to the dataset without crashing the Actor run.

### Pricing

You pay **per page converted**. Pages in documents that fail or cannot be processed are **not** charged. No monthly lock-ins, no minimums — billing scales exactly with your document volume.

### Tips

- For multi-hundred page documents, use `pageRange` to extract only relevant sections.
- Leave `useOcr` as `false` by default — automatic fallback will trigger OCR if minimal text is detected in scanned PDFs.

***

Built and maintained by [Brainiall](https://www.brainiall.com) — production AI APIs for speech, documents, vision and the web.

# Actor input Schema

## `startUrls` (type: `array`):

One or more HTTP/HTTPS URLs pointing to PDF documents to convert to Markdown.

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

Optional page range to convert (e.g., '1-5', '3-10', '1,3,5'). Leave empty to convert all pages in the PDF.

## `useOcr` (type: `boolean`):

Force OCR visual extraction for scanned PDFs or image-heavy documents. Automatic OCR fallback is also enabled by default if text extraction is low.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ],
  "pageRange": "",
  "useOcr": false
}
```

# 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 = {
    "startUrls": [
        {
            "url": "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("vivid_astronaut/pdf-to-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 = { "startUrls": [{ "url": "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("vivid_astronaut/pdf-to-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 '{
  "startUrls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ]
}' |
apify call vivid_astronaut/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

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