# Document to Markdown (PDF, Word, PowerPoint, Excel) + OCR (`fast_data_asap/document-to-markdown`) Actor

Convert PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), EPUB, HTML and images to clean Markdown from URLs, with OCR for scanned PDFs, tables, page selection and RAG chunks. Built on Microsoft MarkItDown, made for LLMs and AI agents.

- **URL**: https://apify.com/fast_data_asap/document-to-markdown.md
- **Developed by:** [Fast Data](https://apify.com/fast_data_asap) (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

Pay per event

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Document to Markdown – PDF, Word, PowerPoint & Excel to Markdown (with OCR)

Convert **PDF to Markdown**, **Word (DOCX) to Markdown**, **PowerPoint to text**, **Excel to Markdown**, plus EPUB, HTML, CSV and images, from any public URL. You get clean, LLM-ready Markdown with headings, lists and tables, page numbers, optional RAG chunks, and built-in **PDF OCR** for scanned documents. It runs on Microsoft's open-source **MarkItDown** library, so you can use it as a hosted **MarkItDown API** without running any servers.

**$1.50 per 1,000 pages (+ $5 per 1,000 pages that need OCR). You pay only for results:** files that fail to download or contain no text are free.

#### Why this document parser

- ✅ **One Actor for all office formats**: PDF, DOCX, PPTX, XLSX/XLS, EPUB, HTML, CSV, JSON, TXT, PNG/JPG/TIFF/WebP
- ✅ **Tables stay tables**: PDF, Word, PowerPoint and Excel tables come out as Markdown tables
- ✅ **OCR only where needed**: scanned pages are detected automatically and OCRed; normal pages are not slowed down or billed for OCR
- ✅ **Page control**: convert only `1-5` or `10-`, and pay only for those pages
- ✅ **Built for RAG and LLMs**: page markers like `<!-- Page 3 -->` for citations, optional paragraph-aware chunks with page ranges
- ✅ **Per-page pricing**: a 2-page invoice costs less than a 300-page report
- ✅ **Share links work**: Google Drive, Google Docs/Sheets/Slides, Dropbox, GitHub and arXiv links are turned into direct downloads

### What you get

One item per document:

| Field | Description |
|---|---|
| `url` | The document URL you sent |
| `status` | `success`, `no_text` (nothing readable found, not charged) or `failed` |
| `fileType` | `pdf`, `docx`, `pptx`, `xlsx`, `xls`, `epub`, `html`, `csv`, `png`, `jpg`, … |
| `title` | Document title from the file's metadata or first page, when available |
| `pageCount` | Pages in the document (slides for PPTX, sheets for Excel) |
| `pagesProcessed` | Pages converted in this run (after your `pages` selection) |
| `ocrPages` | Pages whose text came from OCR |
| `billedPages` | Pages charged (see pricing below) |
| `wordCount` | Number of words in the Markdown |
| `markdown` | The full document as Markdown |
| `chunks` | Optional `[{index, text, pageStart, pageEnd}]` chunks for embeddings |
| `error` | Why a document failed, in plain words |

### Inputs

- **Document URLs** (required): public links to the files. Max 50 MB per file.
- **Pages**: e.g. `1-5`, `1,3,7-9` or `10-`. Applies to PDF pages, PowerPoint slides, Excel sheets and multi-page TIFFs. Empty = everything.
- **OCR**: `auto` (default, OCR only for scanned pages and images), `always` (for PDFs with a broken text layer) or `never`.
- **RAG chunk size**: split the Markdown into chunks of up to N characters (0 = off).
- **Mark page breaks**: adds `<!-- Page N -->` comments (on by default).

```json
{
  "documentUrls": ["https://arxiv.org/pdf/1706.03762"],
  "pages": "1-3",
  "ocr": "auto",
  "outputChunks": 1500
}
```

### Example output

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "success",
  "fileType": "pdf",
  "title": "Attention Is All You Need",
  "pageCount": 15,
  "pagesProcessed": 3,
  "ocrPages": 0,
  "billedPages": 3,
  "wordCount": 1393,
  "markdown": "<!-- Page 1 -->\n\nAttention Is All You Need\n\nAshish Vaswani ...\n\nAbstract\n\nThe dominant sequence transduction models ...",
  "chunks": [{"index": 0, "text": "Attention Is All You Need ...", "pageStart": 1, "pageEnd": 1}]
}
```

### Use cases

- **RAG pipelines**: turn PDFs, Word files and slide decks into Markdown chunks for your vector database
- **AI agents**: let Claude, ChatGPT or your own agent "read this PDF" or "summarise this PowerPoint" from a link
- **n8n, Make and Zapier**: extract text from PDF attachments and Office files inside automations
- **Document search and archiving**: OCR scanned PDFs and faxes into searchable text
- **Data extraction**: read tables from Excel, PDF reports and invoices as Markdown

### How much does it cost?

| Pages | Text pages | Scanned pages (with OCR) |
|---|---|---|
| 100 | $0.15 | $0.65 |
| 1,000 | $1.50 | $6.50 |
| 10,000 | $15.00 | $65.00 |

How pages are counted:

- **PDF**: one page = one PDF page. Pages that need OCR are charged an extra $0.005.
- **Images**: one image (or TIFF frame) = one page + OCR.
- **PowerPoint (PPTX)**: one slide = one page.
- **Excel (XLSX/XLS)**: one sheet = one page (very large sheets: one page per 50,000 characters of output).
- **Word (DOCX), EPUB, HTML, CSV, TXT, JSON**: these have no fixed pages, so every 3,000 characters of Markdown output count as one page (a typical Word page).

Failed downloads and documents without readable text are not charged. With the Apify free plan's monthly credit you can convert thousands of pages at no cost.

### FAQ

**How do I convert a PDF to Markdown?** Paste the PDF link into *Document URLs* and click Start. The Markdown is in the `markdown` field of the result (also downloadable as JSON, CSV or Excel).

**Can it extract text from scanned PDFs (OCR)?** Yes. With OCR on `auto`, pages that have no text layer are rendered and read with an OCR engine (RapidOCR / PaddleOCR models). It works best for printed text in Latin-script languages and Chinese; handwriting is not supported.

**Does it keep tables and headings?** Yes, as far as the file allows. Excel, Word and PowerPoint tables are converted exactly. In PDFs, tables without borders are detected from the text positions (at least 2 rows and 2 columns that line up) and returned as Markdown tables, with exponents kept as `10^19`. PDF headings are recognised from font size, bold text and numbering (`1 Introduction`, `6.1 Machine Translation`) and returned as `#`/`##`/`###` headings. See *Known limitations* below.

**Can I convert Word or PowerPoint files without Microsoft Office?** Yes. DOCX, PPTX and XLSX are read directly. Old binary `.doc` and `.ppt` files are not supported; save them as `.docx`/`.pptx` or PDF first. Legacy `.xls` works.

**What about password-protected or very large files?** Password-protected PDFs cannot be opened. Files up to 50 MB are supported; for long documents use `pages` to convert only what you need.

**Is this the same as Microsoft MarkItDown?** It uses the open-source MarkItDown library (MIT) for Office, HTML and EPUB files, and adds its own PDF layout analysis (headings, borderless tables), per-page PDF handling, page selection, OCR for scans and images, RAG chunks and a hosted API.

### Use it with Claude, ChatGPT and other AI agents

This Actor is made for AI agents: one call turns any document link into Markdown an LLM can read, with page markers it can cite.

1. Add the Apify MCP server to your assistant (e.g. in Claude: Settings → Connectors → add `https://mcp.apify.com`, then sign in with Apify).
2. Ask in plain language. The assistant finds this Actor, runs it and reads the Markdown.

Example prompts:

- "Read this PDF and give me the key findings with page numbers: https://arxiv.org/pdf/1706.03762"
- "Convert this PowerPoint to text and write a one-page summary for my manager: https://…/deck.pptx"

Tips for agents: use `pages` (e.g. `1-20`) for very long PDFs to get an answer within seconds, and `outputChunks` when the text goes into a vector store.

You can also call it through the Apify API, on a schedule, or from Make, Zapier and n8n (HTTP or Apify node: pass `documentUrls`, read `markdown`).

#### Pay per call with x402 – no account needed

AI agents can run this Actor and pay per call with **x402** (USDC stablecoin payments over HTTP) through Apify's agentic payments – no Apify account or API key required. You pay the same pay-per-event prices listed above. Details: [Apify x402 integration](https://docs.apify.com/platform/integrations/x402).

### Known limitations

- **PDF tables** are rebuilt from text positions, because PDFs have no table structure. Cells that span several columns (e.g. a "BLEU" header over two columns) are put into one of the columns they cover, and cells wrapped over several lines can come out as extra rows.
- Tables inside one column of a **two-column page** are usually returned as plain text, and tables whose columns do not line up clearly are kept as text rather than turned into a broken table.
- Exponents are recognised from smaller, raised characters (`10^19`, `n^2`) inside tables; subscripts are joined to the text (`d_model` becomes `dmodel`). In running text, formulas come out as plain text.
- Heading levels follow the numbering (`6` → `##`, `6.1` → `###`) or the font size; documents that use bold body text for headings without numbering may get fewer headings.

### Notes

- Only the files you link are downloaded; nothing is crawled, no login or cookies are used. Use documents you are allowed to process.
- Files are processed in memory for your run only and are not shared.
- Built with MIT/Apache/BSD-licensed open-source software: MarkItDown, pdfminer.six, pdfplumber, pypdf, pypdfium2, RapidOCR with PaddleOCR models.

More Actors for AI agents and data pipelines: [apify.com/fast_data_asap](https://apify.com/fast_data_asap)

# Actor input Schema

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

Public links to the files you want as Markdown: PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX/XLS), EPUB, HTML, CSV, JSON, TXT, or images (PNG, JPG, TIFF, WebP) for OCR. Google Drive, Google Docs, Dropbox and GitHub share links are converted to direct downloads automatically. Max 50 MB per file.

## `pages` (type: `string`):

Optional. Which pages to convert, e.g. "1-5", "1,3,7-9" or "10-" (page 10 to the end). Applies to PDF pages, PowerPoint slides, Excel sheets and multi-page TIFFs. Leave empty for all pages. You only pay for the pages you select.

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

auto: OCR only PDF pages that have (almost) no text layer, plus images. always: OCR every PDF page (for PDFs with a broken text layer). never: no OCR, text layer only.

## `outputChunks` (type: `integer`):

Optional. Also split the Markdown into paragraph-aware chunks of up to this many characters, each with the page range it came from. Ready for embeddings and vector databases. 0 = off.

## `includePageBreaks` (type: `boolean`):

Insert invisible Markdown comments like  (or , ) before every page, so an LLM can cite page numbers.

## `maxConcurrency` (type: `integer`):

How many documents are downloaded and converted at the same time.

## `proxyConfiguration` (type: `object`):

Optional. Downloads go out directly by default. Use a proxy only if a server refuses direct downloads.

## Actor input object example

```json
{
  "documentUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "pages": "1-3",
  "ocr": "auto",
  "outputChunks": 0,
  "includePageBreaks": true,
  "maxConcurrency": 3,
  "proxyConfiguration": {
    "useApifyProxy": 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 = {
    "documentUrls": [
        "https://arxiv.org/pdf/1706.03762"
    ],
    "pages": "1-3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("fast_data_asap/document-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 = {
    "documentUrls": ["https://arxiv.org/pdf/1706.03762"],
    "pages": "1-3",
}

# Run the Actor and wait for it to finish
run = client.actor("fast_data_asap/document-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 '{
  "documentUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "pages": "1-3"
}' |
apify call fast_data_asap/document-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fast_data_asap/document-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/Um0XebUfMIoELV3dd/builds/WV1yakw9uRFcOqgDT/openapi.json
