# Document to Markdown - PDF, Word, PowerPoint and Excel for RAG (`superslowsloth/document-to-markdown`) Actor

Convert PDF, DOCX, PPTX, XLSX, HTML and scanned images to clean Markdown with Docling.

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

## Pricing

from $5.00 / 1,000 page 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?

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

## Document to Markdown — PDF, Word, PowerPoint and Excel for RAG

Converts documents into clean Markdown that a retrieval pipeline can chunk and embed,
using [Docling](https://github.com/docling-project/docling), IBM Research's open-source
document converter. Reading order, headings, lists and table structure are recovered
from the page layout rather than guessed from the text stream, which is the difference
between a table that survives chunking and one that arrives as a column of stray numbers.

Give it a list of URLs. Get back one record per document with the converted text and the
page count it was billed on.

### Input

| Field | Type | Default | What it does |
|---|---|---|---|
| `documentUrls` | array | — | Direct links to the files. PDF, DOCX, PPTX, XLSX, HTML, Markdown, AsciiDoc, CSV and images (PNG, JPEG, TIFF, BMP, WebP). Up to 200 per run. A URL with no extension is accepted — Docling reads the bytes. |
| `outputFormat` | select | `markdown` | `markdown`, `html`, `json`, or `text`. JSON keeps Docling's full layout tree, including reading order and table cell structure. |
| `ocr` | boolean | `false` | Read scanned pages with OCR. Leave off for digital PDFs: OCR is several times slower and reads *worse* than the text layer that is already in the file. |
| `maxPages` | integer | — | Stop each document after this many pages. Billing counts only the pages actually converted. |

### Output

One record per document:

```
source_url        the URL it was fetched from
filename          last path segment, query string stripped
doc_format        pdf, docx, pptx, xlsx, html, md, asciidoc, csv, image
page_count        pages converted — null for formats that have no pages
character_count   length of `content`
content           the converted document, in `output_format`
output_format     which format `content` is in
ocr_used          whether the text was read off the page or lifted from a text layer
tables            tables Docling recovered
pictures          figures Docling recovered
title             the document's own title, when the file carries one
```

Two of those are worth reading carefully.

`page_count` is `null`, never `0`, for HTML, Markdown, AsciiDoc and CSV. Those formats
have no pages at all, and a zero there would read as a measurement — an empty document —
rather than as an inapplicable field. The run still bills one unit for them, because the
conversion still costs compute.

`ocr_used` tells you which of two very different error profiles the text has. A digital
PDF's text layer is exact. OCR output is a good guess, and a RAG index built on the second
while assuming the first will return confident answers from misread numbers.

### Billing

Pay per event, plus a small `actor-start` fee covering the cold start and model load.

| Event | When |
|---|---|
| `page-converted` | One page read from the document's own text layer. |
| `ocr-page-converted` | One page read with OCR. Priced higher because it is measurably more work — on the same 15-page file, OCR cost about three times as much to run. |

The event follows what actually happened, not what you asked for: a document Docling
converted from its text layer is charged the cheaper event even on a run with OCR
switched on.

- A document that fails to convert is **never charged**. Nothing is billed until the
  record is in the dataset.
- A URL whose extension Docling cannot read is rejected before anything is downloaded, so
  it costs nothing.
- The same URL listed twice is converted once and billed once.
- Pageless formats bill one unit each.

### What it does not do

- It does not crawl. Give it the file URLs; it does not follow links to find them.
- It does not read files behind a login. A signed download URL works; a page that needs a
  session does not.
- It does not translate, summarise or otherwise change the text. The output is the
  document, restructured.
- It does not fabricate a page count for a format that has none. See `page_count` above.

### Notes on accuracy

Docling recovers layout with a page-layout model and a table-structure model
(TableFormer), so multi-column pages, headers and footers, and merged table cells come
through in reading order. What it cannot do is invent information the page does not carry:
a scanned page with no OCR yields no text, and a table drawn as an image is a picture.

# Actor input Schema

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

Direct links to the files to convert. PDF, DOCX, PPTX, XLSX, HTML, Markdown, AsciiDoc, CSV and images (PNG, JPEG, TIFF, BMP, WebP). Up to 200 documents per run.

## `outputFormat` (type: `string`):

What each document is converted to. Markdown is what retrieval pipelines usually want; JSON keeps Docling's full layout tree, including reading order and table structure.

## `ocr` (type: `boolean`):

Turn on for scanned documents and photographs of pages. Leave off for digital PDFs: OCR is several times slower and reads worse than the text layer that is already there.

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

Stop each document after this many pages. Leave empty to convert the whole file. Billing counts only the pages actually converted.

## Actor input object example

```json
{
  "documentUrls": [
    "https://arxiv.org/pdf/2408.09869"
  ],
  "outputFormat": "markdown",
  "ocr": false
}
```

# 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://arxiv.org/pdf/2408.09869"
    ]
};

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

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

```

## MCP server setup

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