# Document to Markdown for RAG: PDF, Word, PowerPoint, Excel (`renzxlp/document-to-markdown-rag`) Actor

Turn PDF, Word, PowerPoint, Excel, HTML and CSV files into clean Markdown with retrieval-ready chunks: heading path, page number and token estimate for each chunk. Built for RAG pipelines, vector databases and AI agents.

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

## Pricing

from $4.00 / 1,000 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

## Document to Markdown for RAG: PDF, Word, PowerPoint, Excel

Give the actor links to documents and get back clean Markdown plus chunks that are ready for a vector database. Each chunk keeps the headings it sits under, the PDF page where it starts, and a token estimate, so your retrieval results can cite the exact section and page.

It reads PDF, DOCX, PPTX, XLSX, HTML pages, CSV, TXT, and Markdown files. No API keys and no outside AI services: the conversion runs inside the actor.

### What you get

One item per document. For example, the IRS form W-9 PDF gives:

| Field | Example |
|---|---|
| `fileName`, `format`, `title` | fw9.pdf, pdf, W-9 |
| `pages`, `tables` | 6, 4 |
| `wordCount`, `tokenEstimate`, `chunkCount` | 6624, 8832, 24 |
| `markdown` | The whole document as Markdown, with `#` headings and tables |
| `chunks` | `[{"index": 3, "text": "...", "tokenEstimate": 320, "headingPath": ["W-9", "..."], "page": 1}, ...]` |
| `warnings` | Pages without a text layer, or pages left out by the page limit |

### How it converts

- **PDF**: headings come from font size, tables become Markdown tables, and headers or footers that repeat on most pages are removed. Page numbers are kept for every chunk.
- **Word**: headings, bulleted and numbered lists, and tables.
- **PowerPoint**: one section per slide with its title, bullets, tables, and speaker notes.
- **Excel**: one table per sheet, up to 1,000 rows each.
- **HTML**: the main content only. Navigation, scripts, footers, and sidebars are dropped.

### Input

```json
{
    "documentUrls": ["https://www.irs.gov/pub/irs-pdf/fw9.pdf", "https://www.python.org/about/"],
    "chunkSize": 500,
    "chunkOverlap": 50,
    "maxPagesPerDocument": 200,
    "includeTables": true,
    "includeMarkdown": true
}
```

- **chunkSize** and **chunkOverlap** are in tokens. A new section always starts a new chunk, and short paragraphs aren't split across chunks.
- **maxPagesPerDocument** caps long PDFs. The `warnings` field says when it was applied.

### Pricing

You pay per converted document, plus a tiny fee when the run starts. Documents that fail, or that have no text at all, aren't charged. Set a maximum charge per run in the run options and the actor stops there.

### Good to know

- Scanned PDFs without a text layer are reported in `warnings`. This version doesn't do OCR.
- The actor reads robots.txt before downloading and skips any file a site disallows. Files must be public links, up to 50 MB each.
- You're responsible for having the right to process the documents you send.

# Actor input Schema

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

One public link per line: PDF, DOCX, PPTX, XLSX, HTML page, CSV, TXT or MD. Up to 50 MB each.

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

Approximate size of each chunk, in tokens.

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

Tokens repeated from the end of a chunk at the start of the next one, within the same section.

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

Longer PDFs are cut here, and the warnings field says so.

## `includeTables` (type: `boolean`):

Convert tables to Markdown tables.

## `includeMarkdown` (type: `boolean`):

Turn off to get only the chunks and metadata.

## Actor input object example

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "chunkSize": 500,
  "chunkOverlap": 50,
  "maxPagesPerDocument": 200,
  "includeTables": true,
  "includeMarkdown": true
}
```

# Actor output Schema

## `documents` (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"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("renzxlp/document-to-markdown-rag").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"] }

# Run the Actor and wait for it to finish
run = client.actor("renzxlp/document-to-markdown-rag").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"
  ]
}' |
apify call renzxlp/document-to-markdown-rag --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,renzxlp/document-to-markdown-rag"
        }
    }
}
```

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/VLWMNMwJBCo29GDeA/builds/YpxLh7OKyaraeZ8O0/openapi.json
