# PDF & More to Markdown with Tables, OCR & RAG Chunks (`bite-sized-insights/document-to-markdown`) Actor

Convert PDF, DOCX, PPTX, XLSX, HTML and image links into clean Markdown. Get per-page text, extracted tables and optional RAG-ready chunks with source page numbers. Scanned pages are read with OCR. Built for LLM and search pipelines.

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

## Pricing

from $0.01 / 1,000 dataset items

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

Convert PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), HTML and images (PNG, JPEG, TIFF, BMP, WebP) to clean, LLM-ready Markdown, with per-page text, tables and page-referenced chunks for RAG. Paste a list of document links, get one dataset row per document, and pay per converted page: **50 pages cost $0.125** (from $2.50 per 1,000 pages), tables and chunks included.

### Supported file formats

| Type | Formats | Notes |
|---|---|---|
| PDF | `.pdf` | Digital and scanned; scanned pages are read with OCR |
| Word | `.docx` | Headings, lists and tables keep their structure |
| PowerPoint | `.pptx` | One page per slide |
| Excel | `.xlsx` | One page per sheet |
| Web pages | HTML, XHTML | Direct page links |
| Images | PNG, JPEG, TIFF (multi-page too), BMP, WebP | Always read with OCR |

The type is detected from the file itself, so a wrong extension or content type does not matter. Legacy binary Office files (DOC, PPT, XLS), plain text, archives and password-protected files are not supported.

### What can I use it for?

- **RAG and LLM pipelines**: Markdown and chunks that respect paragraph and table boundaries, each with its source pages and nearest heading, so answers can cite the page they came from.
- **Search and knowledge bases**: index contracts, manuals, reports and slide decks with page numbers.
- **Data extraction**: pull tables out of reports and spreadsheets as Markdown and as rows of cells.
- **Archive digitising**: turn scanned PDFs and photographed pages into searchable text with OCR.
- **AI agents**: give an agent a tool that turns any document link into text it can read (see the MCP section).

### What does it do?

- **Converts the formats you actually receive**: PDF, DOCX, PPTX, XLSX, HTML and images (PNG, JPEG, TIFF, BMP, WebP). The type is detected from the file itself, so a wrong file extension or content type does not matter.
- **Clean Markdown**: headings, lists and tables keep their structure, in reading order.
- **Per-page text**: every row carries the text of each page (slide, sheet) next to the full document, so you can cite or filter by page.
- **Tables**: returned as Markdown and as rows of cells, with the page they were found on. No extra fee.
- **Optional chunks for RAG**: set a chunk size and each document is also split into chunks of that size. Every chunk lists the pages it came from and its nearest heading.
- **OCR for scans**: scanned PDF pages and images are read automatically. Switch OCR off when you know your files contain real text.
- **Fast on digital PDFs**: plain text pages are read directly, pages with tables, columns or scans get a full analysis. The price is the same.
- **No file retention**: the source document is downloaded into memory, converted and discarded. It is never written to disk or stored, and nothing is kept after the request. The result exists only in your run's dataset.
- **Safe by design**: only public http(s) links are fetched, downloads are limited to 50 MB, and the page limit keeps a single huge file from running up your bill.

Direct document links only. A link to a web page that merely shows or embeds a document (a viewer, a login page) is converted as HTML, not as the document behind it.

### How much does it cost?

You pay per converted page. Tables, chunks and fast mode are included, there is no per-document, per-table or per-chunk fee.

| Example | Cost at Free plan prices |
|---|---|
| 50 pages of digital PDF | 50 x $0.0025 = **$0.125** (plus $0.00006 start and row fees) |
| 1,000 pages of digital PDF | **$2.50** |
| 20 scanned pages with OCR | 20 x $0.008 = **$0.16** |
| 100 Word files of 5 sections each | 500 x $0.0025 = **$1.25** |

Paid Apify plans are cheaper, see [Pricing](#pricing-pay-per-page) for all plans and the exact formula.

### How does it compare?

| | This actor | Typical alternatives |
|---|---|---|
| Pricing unit | The page, as the document counts it | Per document (same fee for 2 or 200 pages), or add-ons |
| Tables | Included in the page price | Sometimes an extra fee per table |
| Chunks for RAG | Included, with source pages and heading | Often not offered, or charged per chunk |
| Scanned pages | OCR price replaces the page price (never both) | Often charged on top of the page price |
| Formats | PDF, Word, PowerPoint, Excel, HTML, images in one run | Frequently PDF only |
| Page references | On every page, table and chunk | Often only the full text |
| Cost control | `maxPagesPerDocument`; failed documents are free | Varies |

### Quick start

```json
{
    "urls": ["https://arxiv.org/pdf/1706.03762"],
    "chunkSize": 512
}
```

Click **Start**. Each document is added to the dataset as soon as it is converted. A row looks like this (shortened, the full shape is under [Output](#output)):

```json
{
    "url": "https://arxiv.org/pdf/1706.03762",
    "status": "success",
    "format": "pdf",
    "pages_converted": 15,
    "markdown": "# Attention Is All You Need\n\n...",
    "tables": [{"index": 0, "page": 6, "rows": [["Layer Type", "Complexity per Layer"]]}],
    "chunks": [{"index": 0, "pages": [1, 2], "heading": "Abstract", "tokens": 480}]
}
```

### Input parameters

| Parameter | Type | Required | Description |
|---|---|---|---|
| `urls` | Array\[String] | Yes | Links to the documents. Up to 100 per run, up to 2048 characters each. |
| `ocr` | Boolean | No | Read scanned pages and images with OCR (on by default), billed at the OCR price. |
| `extractTables` | Boolean | No | Return tables in the `tables` field (on by default). No extra fee. |
| `fastMode` | Boolean | No | Read plain PDF text pages directly, which is faster (on by default). Same price. |
| `chunkSize` | Integer | No | `0` (default) for no chunks, otherwise 100-4000 tokens (about 4 characters each). |
| `maxPagesPerDocument` | Integer | No | Convert only the first N pages of each document. 1-200, default 100. |

Entries without a scheme are treated as `https://`. Links to private or local addresses, links with credentials and malformed links are rejected as invalid input before anything is fetched.

### Output

One row per input document. Every key is always present: missing values are `null`, lists are empty, never omitted.

#### Converted PDF

```json
{
    "url": "https://example.com/report.pdf",
    "status": "success",
    "format": "pdf",
    "title": "Quarterly Report",
    "total_pages": 12,
    "pages_converted": 12,
    "ocr_pages": 0,
    "truncated": false,
    "markdown": "# Quarterly Report\n\nRevenue grew by twelve percent...",
    "pages": [
        {"page": 1, "text": "# Quarterly Report\n\nRevenue grew by twelve percent...", "ocr": false, "method": "fast"}
    ],
    "tables": [
        {
            "index": 0,
            "page": 3,
            "markdown": "| Region | Revenue |\n|---|---|\n| EMEA | 4.1M |",
            "rows": [["Region", "Revenue"], ["EMEA", "4.1M"]]
        }
    ],
    "chunks": [
        {
            "index": 0,
            "text": "# Quarterly Report\n\nRevenue grew...",
            "pages": [1, 2],
            "heading": "Quarterly Report",
            "tokens": 480
        }
    ],
    "error_code": null,
    "error": null
}
```

#### Failed document

```json
{
    "url": "https://example.com/notes.txt",
    "status": "failed",
    "format": null,
    "title": null,
    "total_pages": null,
    "pages_converted": 0,
    "ocr_pages": 0,
    "truncated": false,
    "markdown": null,
    "pages": [],
    "tables": [],
    "chunks": [],
    "error_code": "unsupported_format",
    "error": "Unsupported document type. Supported: PDF, DOCX, PPTX, XLSX, HTML and images."
}
```

`status` is one of:

- `success` - the document was converted
- `partial` - the time budget for the document ran out; `pages` holds everything converted until then
- `failed` - nothing could be converted; `error_code` and `error` say why (not billed)

`error_code` values: `blocked_url` (private or unresolvable address), `download_failed`, `too_large` (over 50 MB), `unsupported_format`, `invalid_document` (corrupt, empty or password protected), `too_many_pages` (over 2000 pages), `conversion_failed`, and `service_unavailable` (the conversion service could not be reached, returned an error or declined the request; try again), and `time_limit` (the document was not started because too little time was left in the run; it is not billed, run it again).

Invalid input (no valid URL, out-of-range option) fails the run before any row is written. Documents not started because the run's budget was used up get no row. `format` is `null` for failed rows unless the file was identified before it failed.

### What counts as a page

| Format | One page is | OCR page |
|---|---|---|
| PDF | One PDF page | A scanned page (an image with no real text), when OCR is on |
| Image | The image (each frame of a multi-page TIFF) | Every image, when OCR is on |
| PowerPoint | One slide | Never |
| Excel | One sheet | Never |
| Word, HTML | One section of about 3,000 characters of Markdown | Never |

`pages[].method` shows how each page was converted (`fast`, `layout`, `ocr` or `native` for Word, PowerPoint, Excel and HTML). It is informational and never changes the price.

Blank pages and pages with real text are never OCR pages. `pages_converted` and `ocr_pages` in every row show exactly what was billed.

### Pricing: pay per page

| Event | Price |
|---|---|
| Standard page | $0.0025 (**$2.50 per 1,000 pages**) |
| OCR page | $0.008 (**$8.00 per 1,000 pages**), instead of the standard price for that page |

Prices are for the Free plan. Paid Apify plans get lower prices:

| Plan | Standard page | OCR page |
|---|---|---|
| Free | $0.0025 | $0.008 |
| Starter | $0.0024 | $0.0076 |
| Scale | $0.0021 | $0.0068 |
| Business | $0.0016 | $0.0052 |

Tables, chunks and fast mode cost nothing extra: there is no per-table or per-chunk fee, only the page price.

A flat start fee of $0.00005 per run applies, and Apify's platform dataset-item fee ($0.00001 per row) applies to every row written to the dataset, failed rows included. Only the pages that were actually delivered are billed: failed documents cost nothing beyond the row fee, and a document cut short by the page limit is billed for the pages it contains.

#### Pricing examples

| Documents | Cost at Free plan prices |
|---|---|
| 1 text PDF, 20 pages | 20 x $0.0025 + $0.00005 + $0.00001 = $0.05006 |
| 1 text PDF, 50 pages | 50 x $0.0025 + $0.00005 + $0.00001 = $0.12506 |
| 1 scanned PDF, 20 OCR pages | 20 x $0.008 + $0.00005 + $0.00001 = $0.16006 |
| 100 Word files of 5 sections each | 500 x $0.0025 + $0.00005 + 100 x $0.00001 = $1.25105 |

Keep costs down with `maxPagesPerDocument`, and switch `ocr` off for files that contain real text.

#### Free test runs

New users on Apify's free plan get up to 5 free runs of this actor (lifetime total), each capped to 3 documents of 5 pages. Runs started via the Apify Console's "Test" button have the same caps regardless of plan and do not count against the 5 free runs.

### How long does a run take?

Documents are converted two at a time and results appear in the dataset as each one finishes.

| Document | Typical time |
|---|---|
| Word, PowerPoint, Excel, HTML | Under a few seconds |
| PDF with a text layer, plain pages (fast mode) | A fraction of a second per page |
| PDF pages with tables, columns or charts | About a second per page |
| Scanned PDF or image with OCR | Several seconds per page |

A very large scan can reach the time budget for one document; it then comes back as `partial` with the pages finished so far. Lower `maxPagesPerDocument` or split the file to avoid that.

### Use it from code

Replace `<APIFY_TOKEN>` with your API token from the Apify Console (Settings, API and integrations).

```bash
curl -X POST "https://api.apify.com/v2/acts/wve8O2NFWNuVf8hIa/runs?token=<APIFY_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"urls": ["https://arxiv.org/pdf/1706.03762"], "chunkSize": 512}'
```

The call returns the run immediately; read the results from the run's default dataset when it has finished.

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("wve8O2NFWNuVf8hIa").call(run_input={
    "urls": ["https://arxiv.org/pdf/1706.03762"],
    "chunkSize": 512,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["status"], item["pages_converted"], item["title"])
```

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('wve8O2NFWNuVf8hIa').call({
    urls: ['https://arxiv.org/pdf/1706.03762'],
    chunkSize: 512,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].status, items[0].markdown);
```

Use the asynchronous run shown above for long documents. Apify's synchronous run endpoints stop waiting after about five minutes, which is shorter than the time a large scan can need.

### Use with AI agents (MCP)

Connect an AI client such as Claude Desktop, Cursor or VS Code to the Apify MCP server and it can call this actor as a tool. Authenticate with OAuth or your API token:

```json
{
    "mcpServers": {
        "apify-document-to-markdown": {
            "url": "https://mcp.apify.com/?actors=wve8O2NFWNuVf8hIa",
            "headers": {"Authorization": "Bearer <APIFY_TOKEN>"}
        }
    }
}
```

Ask the agent to convert a document link; it passes the same input as in the table above and gets the dataset rows back. Billing is the same as for a normal run. Agents should leave `chunkSize` at `0` unless they need RAG chunks: every chunk repeats text that is already in `markdown` and `pages`, which adds another full copy of the text to the agent's context.

### Troubleshooting

| Symptom | Cause | Fix |
|---|---|---|
| `blocked_url` | Private or local address, or the host name does not resolve | Use a public link |
| `download_failed` | Server error, too many redirects, slower than 60 s, or expired link | Use a stable public URL |
| `too_large` | Over 50 MB | Compress or split the file |
| `unsupported_format` | Plain text, an archive or another unsupported file | Link a PDF, Office, HTML or image file |
| `invalid_document` | Corrupt, empty or password protected | Re-export it without a password |
| `too_many_pages` | Over 2000 pages | Split the document |
| `conversion_failed` | The file could not be read | Retry; re-export the file |
| `service_unavailable` | Service unreachable or declined the request; see `error` | Try again later |
| `time_limit` | Not started, not enough time left in this run | Run the document again, or send fewer documents per run |
| `partial` status | Time budget ran out part way | Lower `maxPagesPerDocument`; split the file |
| Scanned pages come back empty | `ocr` is off | Switch **Read scanned pages (OCR)** on |
| Only 3 documents of 5 pages done | Free plan and Console test runs are capped | Use a paid plan |

### FAQ

#### Why is my scanned PDF billed at the OCR price?

Pages that consist of an image and have (almost) no embedded text are scans, and reading them costs more. If your PDFs contain real text, turn **Read scanned pages (OCR)** off: scanned pages then come back without text and are billed as standard pages.

#### Can I convert only part of a long document?

Yes. `maxPagesPerDocument` converts the first N pages. The row shows the document's real page count in `total_pages` and `truncated: true` when pages were left out.

#### How much does a typical document cost?

A 50-page digital PDF costs 50 x $0.0025 = $0.125 on the Free plan, plus $0.00006 in start and row fees. The same document with scanned pages costs 50 x $0.008 = $0.40. `pages_converted` and `ocr_pages` in each row show what was billed.

#### What is the best way to get a PDF into an LLM or vector database?

Set `chunkSize` to 256-512 and load the `chunks` field: every chunk has its text, source `pages`, nearest `heading` and token estimate. Use `markdown` instead when you want the whole document in one piece.

#### Which formats are supported?

PDF, DOCX, PPTX, XLSX, HTML and images (PNG, JPEG, TIFF, BMP, WebP). Legacy binary Office files (DOC, PPT, XLS) are not supported; save them as DOCX, PPTX or XLSX first.

#### Are tables charged extra?

No. Tables, chunks and the `pages` text are part of the page price. Switch **Extract tables** off only if you do not need the `tables` field.

#### What does fast mode change?

Plain text pages of digital PDFs are read directly from the file, which is much faster. Pages with tables, several columns, charts or scans are still analysed in full, so structure is not lost. The price per page and the page count are identical with fast mode on or off. Turn it off if you want every page analysed the same way; headings and whitespace can differ slightly between the two. `pages[].method` tells you which path each page took.

#### Which chunk size should I use?

Common embedding models work well with 256-512 tokens. Chunks never cut through a table when it fits, and each one lists its source pages in `pages`.

#### Does it work for password-protected files?

No. Protected documents are reported as `invalid_document`.

#### Can I convert a document behind a login?

No. Only public links are fetched. Links that need a login, a cookie or an allowlisted IP fail with `download_failed`. Use a public link or a signed URL that is valid for anyone.

#### Are my documents stored?

No. The conversion service holds the downloaded file in memory only while converting it, never writes it to disk and keeps no copy afterwards. Document content and URLs are not sent to monitoring. The converted output is stored only in your run's dataset, under your Apify account's retention settings.

#### Does this actor use a proxy?

No. It calls a dedicated conversion service, and the service fetches your public document links from its own server address, not from Apify's IPs or yours.

### Related Actors

- [transcribe audio and video to text](https://apify.com/bite-sized-insights/transcription) - speech to text with timestamps, SRT and VTT.
- [URL to PDF Converter](https://apify.com/bite-sized-insights/url-to-pdf-converter) - web pages and HTML to print-ready PDFs.
- [full-page website screenshots](https://apify.com/bite-sized-insights/website-screenshot-api) - desktop and mobile captures of any URL.
- [bulk image converter](https://apify.com/bite-sized-insights/bulk-image-converter-compressor-and-resizer) - convert, compress and resize images.

### Disclaimer

Only convert documents you are allowed to process. Conversion quality depends on the source file: scans of poor quality, unusual layouts and text that continues across a page break can reduce accuracy. Text running across a page break may be attributed to the page where it starts.

***

**Need help?** Open an issue on the actor's repository or contact support through Apify Console.

# Actor input Schema

## `urls` (type: `array`):

Direct file links, not viewer pages: PDF, DOCX, PPTX, XLSX, HTML, images. Max 50 MB each.

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

Read scanned pages and images with OCR. Billed at the OCR page price, see Pricing.

## `extractTables` (type: `boolean`):

Return tables as Markdown and rows of cells. No extra fee, included in the page price.

## `fastMode` (type: `boolean`):

Read plain PDF text pages directly (faster). Tables and scans get full analysis.

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

Also split each document into RAG chunks of this many tokens. 0 = none, else 100-4000.

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

Convert only the first N pages of each document (1-200). Only converted pages are billed.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "ocr": true,
  "extractTables": true,
  "fastMode": true,
  "chunkSize": 0,
  "maxPagesPerDocument": 100
}
```

# Actor output Schema

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

One row per input document: Markdown, page text, tables, chunks and the pages billed

# 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 = {
    "urls": [
        "https://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bite-sized-insights/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 = { "urls": ["https://arxiv.org/pdf/1706.03762"] }

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

```

## MCP server setup

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