# Doc to Markdown - PDF, DOCX & HTML to Markdown Converter (`cuantic_data/doc-to-markdown`) Actor

Converts your own PDF, DOCX, HTML or TXT file into clean Markdown. Built for RAG pipelines, LLM ingestion and AI agents that need plain, structured text instead of binary document formats.

- **URL**: https://apify.com/cuantic\_data/doc-to-markdown.md
- **Developed by:** [Cuantic Data](https://apify.com/cuantic_data) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## 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

## Doc to Markdown — PDF, DOCX & HTML to Markdown Converter

Converts a PDF, DOCX, HTML or TXT document into clean Markdown. Built to
feed RAG pipelines, index content for an LLM, or prepare documents for use
by an AI agent.

### What it does

- Downloads the file from the URL you provide.
- Detects the format by extension or `Content-Type`.
- Converts to Markdown, preserving headings, lists and bold text when the
  source format carries them (DOCX, HTML). PDFs are converted to plain text
  (see limitation below).

### Who it's for

- RAG/agent pipelines that need plain text before indexing.
- Turning PDF/Word reports or contracts into a format that's easy to process
  with another program.

### Input

| Field | Type | Required | Description |
|---|---|---|---|
| `fileUrl` | string | Yes | Direct http(s) URL to the file. Maximum 20 MB. |

```json
{ "fileUrl": "https://example.com/report.pdf" }
```

### Output

```json
{
  "sourceUrl": "https://example.com/report.pdf",
  "format": "pdf",
  "markdown": "Extracted text from the document...",
  "characterCount": 4213
}
```

### Formats supported today (and what's not yet)

| Format | Support | Note |
|---|---|---|
| PDF | Yes | Plain text, no heading structure (see `TERMS.md`) |
| DOCX | Yes | With structure (headings, lists, bold) |
| HTML | Yes | With structure |
| TXT | Yes | Passthrough |
| XLSX / XLS | **Not yet** | The Actor returns an explicit error, not an incorrect result |
| PPTX / PPT | **Not yet** | Same as above |
| DOC (Word 97-2003) | **No** | Use `.docx`, PDF or HTML instead |

### Pricing

Pay-per-event, provisional. Starting reference: USD 0.01 per document
converted (`03-plan.md` §2). Final calibration against real compute before
publishing.

### How to call it

```bash
curl "https://api.apify.com/v2/acts/cuantic-data~doc-to-markdown/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"fileUrl": "https://example.com/report.pdf"}'
```

### Terms and limits

See [`TERMS.md`](./TERMS.md): the document is always supplied by the user,
the conversion libraries are open source under permissive licenses
(Apache-2.0, BSD-2-Clause, MIT), and format limitations are disclosed, not
hidden.

### FAQ

**Why doesn't my PDF have headings in the result?**
This is a known limitation of PDF text extraction: the format doesn't carry
"this is an H1" as metadata, only visually positioned text. To keep
headings, convert from DOCX or HTML if you have that version.

**Do you support Excel/PowerPoint?**
Not yet. The Actor tells you explicitly instead of failing silently or
returning an empty result.

**Found a bug?**
Email `cuanticwindows@gmail.com` — we reply within 72 hours.

***

See `build/README.md` for how to run tests and publish this Actor.

# Actor input Schema

## `fileUrl` (type: `string`):

Direct http(s) URL to the file. Supported formats today: .pdf, .docx, .html, .txt. Excel and PowerPoint are not supported yet.

## Actor input object example

```json
{
  "fileUrl": "https://bitcoin.org/bitcoin.pdf"
}
```

# Actor output Schema

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

The document converted to Markdown, as a single dataset item.

## `runSummary` (type: `string`):

Source URL, detected format and resulting character count.

# 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 = {
    "fileUrl": "https://bitcoin.org/bitcoin.pdf"
};

// Run the Actor and wait for it to finish
const run = await client.actor("cuantic_data/doc-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 = { "fileUrl": "https://bitcoin.org/bitcoin.pdf" }

# Run the Actor and wait for it to finish
run = client.actor("cuantic_data/doc-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 '{
  "fileUrl": "https://bitcoin.org/bitcoin.pdf"
}' |
apify call cuantic_data/doc-to-markdown --silent --output-dataset

```

## MCP server setup

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