# PDF to Markdown: DOCX, XLSX & PPTX to Markdown for RAG (`ceibadata/document-to-markdown`) Actor

PDF to Markdown converter: turn PDF, Word, Excel (.xlsx), PowerPoint (.pptx), HTML and text files into clean LLM-ready Markdown with headings, lists and tables. Get full text, per-page/sheet/slide text, metadata or RAG chunks. Flags scanned PDFs. Built for AI agents and RAG.

- **URL**: https://apify.com/ceibadata/document-to-markdown.md
- **Developed by:** [Ceiba Data](https://apify.com/ceibadata) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 converted documents

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, Word, Excel & PowerPoint to Markdown for RAG

Convert **PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), HTML, Markdown and plain-text files** into clean, LLM-ready **Markdown**. Headings, paragraphs, numbered and bulleted lists and links are kept; Word tables, Excel sheets, PowerPoint tables and simple PDF tables (text in aligned columns) become Markdown tables. Choose one row per document, one row per page / sheet / slide, or ready-to-embed **RAG chunks** with overlap.

Built for AI agents, RAG pipelines, vector databases and no-code automations (n8n, Make, Zapier).

### What you get

- **Markdown** with `#` headings detected from font sizes in PDFs and from styles in Word files.
- **Per-page text** for PDFs, with page numbers.
- **Excel (.xlsx)**: every sheet becomes a `##` section with a Markdown table (first row as header). Shared strings, dates (as ISO), booleans and cached formula values are read; empty rows and columns are dropped; hidden sheets are marked.
- **PowerPoint (.pptx)**: one `##` section per slide with its title, bullets (with indent levels), text boxes, tables and, optionally, speaker notes.
- **RAG chunks** that break at headings and paragraphs, with the nearest heading attached to each chunk and configurable size and overlap.
- **Metadata**: title, author, subject, keywords, creator, producer, creation and modification dates, PDF version, page count, characters and words.
- **Scanned-page detection**: `pagesWithoutText` and `likelyScanned` tell you which PDFs need OCR, instead of silently returning empty text.
- **Page ranges** (`"1-5, 8"`) and a per-PDF page limit.
- Files that fail (dead link, password-protected, not a document) become an `error` row with a clear message and are **never charged**.

### Input

| Field | What it does |
|---|---|
| `documentUrls` | Public links to PDF, DOCX, XLSX, PPTX, HTML, Markdown or text files. Type is detected from content. |
| `outputMode` | `document` (default), `pages` or `chunks`. |
| `chunkSize`, `chunkOverlap` | Chunk size and overlap in characters (chunks mode). |
| `pageRange`, `maxPagesPerDocument` | Limit which PDF pages (or PowerPoint slides) are read. |
| `maxRowsPerSheet` | Excel: rows read per sheet (default 5,000). |
| `includeSlideNotes` | PowerPoint: add speaker notes (default true). |
| `base64Files` | `[{"name": "a.pdf", "data": "<base64>"}]` for files you cannot host. |
| `htmlOrText` | Raw HTML or text strings. |

Run it with empty input to get a **free demo** with a built-in sample PDF.

#### Example

```json
{
  "documentUrls": ["https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"],
  "outputMode": "chunks",
  "chunkSize": 1200,
  "chunkOverlap": 120
}
```

### Output (document mode)

```json
{
  "source": "https://example.com/report.pdf",
  "status": "ok",
  "format": "pdf",
  "title": "Quarterly sales report",
  "pageCount": 3,
  "pagesProcessed": 3,
  "likelyScanned": false,
  "pagesWithoutText": [3],
  "chars": 412,
  "words": 63,
  "markdown": "# Quarterly sales report\n\nSales grew 12% ...",
  "pages": [{ "page": 1, "text": "...", "chars": 268 }],
  "metadata": { "author": "...", "createdAt": "2026-11-02T00:38:16Z" },
  "error": null
}
```

In `chunks` mode each row has `chunkIndex`, `chunkCount`, `heading` and `text`. In `pages` mode each row has `page`, `markdown` and `text` (plus `sheet`, `rows` and `columns` for Excel, or `slideTitle` and `notes` for PowerPoint).

### Use cases

- **RAG pipelines**: PDFs, Word, Excel and PowerPoint files to clean Markdown chunks with headings, ready for embeddings.
- **Spreadsheets for LLMs**: give an agent an Excel workbook as Markdown tables it can read and reason about.
- **AI agents**: let an agent read a PDF, DOCX, XLSX or PPTX link and answer questions about it.
- **Knowledge bases**: convert manuals, policies and reports to Markdown for Notion, Confluence or a docs site.
- **Data extraction**: get page-by-page text and metadata, and flag scanned PDFs that need OCR.

### Use with AI agents (MCP)

Every Apify Actor is also a tool for AI agents. Add this Actor to Claude, Cursor, VS Code or any MCP client with the Apify MCP server:

```text
https://mcp.apify.com?tools=ceibadata/document-to-markdown
```

Or run it locally:

```bash
npx -y @apify/actors-mcp-server --tools ceibadata/document-to-markdown
```

Then just ask, for example:

> Convert this PDF to Markdown chunks of about 1,200 characters so I can index it: https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf

From code, one call returns the results:

```bash
curl -X POST "https://api.apify.com/v2/acts/ceibadata~document-to-markdown/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
  -H 'Content-Type: application/json' -d @input.json
```

### Pricing

Pay per event, no monthly fee:

- **Converted document**: one charge per file converted successfully. Includes up to 20 PDF pages. Word, Excel and PowerPoint files are one charge each, whatever their size.
- **Extra page**: each PDF page beyond the first 20.

Failed files and demo runs are free. Check the Pricing tab for current prices.

### Limits

- Text-layer extraction only: scanned PDFs (images of text) are flagged with `likelyScanned`, not OCR'd.
- Files up to 50 MB. Only public http(s) URLs; private network addresses are refused.
- Complex multi-column PDF layouts are read in the PDF's text order.
- Excel: formulas without a saved value are shown as the formula (`=B2+B3`); charts and images are skipped. Old binary formats (.xls, .ppt, .doc) are not supported.

### Support

Open an issue on the Issues tab. Built and maintained by **Ceiba Data**, a small data studio operated with AI.

# Actor input Schema

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

Public links to PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), HTML, Markdown or plain-text files. The type is detected from the file content, not the extension. Leave empty for a free demo with a built-in sample PDF.

## `outputMode` (type: `string`):

document = one row per file with the full Markdown (and per-page text); pages = one row per PDF page, Excel sheet or PowerPoint slide; chunks = one row per RAG chunk, ready for embeddings.

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

Target maximum size of each chunk in chunks mode. Chunks break at headings and paragraphs when possible.

## `chunkOverlap` (type: `integer`):

Characters repeated from the end of the previous chunk, so context is not lost at the boundary.

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

Only these pages of each PDF (or slides of each PowerPoint), for example "1-5, 8, 10-12". Leave empty for all.

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

Pages beyond this limit are skipped and the row is marked truncated.

## `includePageText` (type: `boolean`):

Add a pages array with the text of every PDF page to each document row.

## `mainContentOnly` (type: `boolean`):

For HTML files, keep only <main> or <article> (or drop nav, header, footer and aside).

## `maxRowsPerSheet` (type: `integer`):

Rows beyond this limit in each sheet are skipped and the row is marked truncated. Empty rows and columns are always dropped.

## `includeSlideNotes` (type: `boolean`):

Add each slide's speaker notes below its content.

## `base64Files` (type: `array`):

Files passed directly, as \[{"name": "report.pdf", "data": "<base64>"}]. Data URLs are accepted.

## `htmlOrText` (type: `array`):

HTML or plain text passed directly, one document per item.

## `maxDocuments` (type: `integer`):

Stop after this many documents in one run.

## Actor input object example

```json
{
  "documentUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "outputMode": "document",
  "chunkSize": 1500,
  "chunkOverlap": 150,
  "maxPagesPerDocument": 500,
  "includePageText": true,
  "mainContentOnly": true,
  "maxRowsPerSheet": 5000,
  "includeSlideNotes": true,
  "maxDocuments": 1000
}
```

# Actor output Schema

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

Rows with source, status, format, title, pageCount, markdown or text, chunk fields, metadata, likelyScanned and error.

## `summary` (type: `string`):

JSON record with converted, failed, pagesProcessed, extraPagesCharged and stoppedEarly.

# 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.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("ceibadata/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://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

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

```

## MCP server setup

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