# PDF & Documents to Markdown / JSON (`badr_xba/pdf-documents-to-markdown`) Actor

Convert public PDF, Word, PowerPoint, Excel and HTML documents into clean Markdown and per-page JSON with headings, tables and metadata. Optional OCR. Pay per page.

- **URL**: https://apify.com/badr_xba/pdf-documents-to-markdown.md
- **Developed by:** [Badr Bouargan](https://apify.com/badr_xba) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.75 / 1,000 converted pages

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

### What is PDF & Documents to Markdown / JSON?

**PDF & Documents to Markdown / JSON** turns public PDF, Word, PowerPoint, Excel and HTML documents into clean Markdown and structured JSON, so you can feed them to an LLM, a RAG pipeline, a search index or a spreadsheet. You pay per converted page, with no start fee.

- **Convert PDFs to Markdown** with real headings, joined paragraphs, bullet lists and ruled tables as Markdown tables.
- **Get per-page JSON** (optional): text, Markdown, headings and tables of every page, ready for chunking.
- **Read Word (.docx), PowerPoint (.pptx), Excel (.xlsx), HTML and text** files too. The format is read from the file itself, not from the address. Web page menus, language lists and tables of contents are left out, so you do not pay for them.
- **Extract metadata**: title, author, subject, keywords, creation and modification dates (ISO 8601) and language.
- **Read scanned PDFs with OCR** (optional, open-source Tesseract engine, 7 languages).
- **Use your own files**: point the Actor to one of your Apify key-value stores instead of public URLs.
- **Stay polite**: each host's robots.txt is respected, no login, no CAPTCHA solving, no anti-bot bypass.

Use cases: **AI and RAG teams** loading reports and papers into a vector store, **analysts** pulling tables out of public filings, **researchers** batch-reading papers, **no-code builders** turning documents into rows for Make, n8n or Zapier.

### What data can you extract from a PDF or document?

| Field | Description | Example |
|---|---|---|
| 📄 `title` | Document title (metadata, else the biggest heading, else the file name) | `Form W-9 (Rev. March 2024)` |
| 🔗 `url` | Address of the document | `https://www.irs.gov/pub/irs-pdf/fw9.pdf` |
| 🧾 `format` | pdf, docx, pptx, xlsx, html or text (read from the bytes) | `pdf` |
| 📑 `pages` / `pagesConverted` | Pages in the file / pages converted | `6` / `6` |
| ✍️ `markdown` | The whole document as Markdown | `Form W-9 (Rev. March 2024) ...` |
| 📊 `tablesFound` | Tables written as Markdown tables | `1` |
| 🧩 `pagesData` | Optional per-page JSON: text, Markdown, headings, tables, OCR flag | `[{"page": 1, ...}]` |
| 👤 `metadata.author` | Author from the file (null when the file has none) | `SE:W:CAR:MP` |
| 📅 `metadata.createdAt` | Creation date, ISO 8601 UTC | `2024-03-06T13:18:13Z` |
| 🌐 `metadata.language` | ISO 639-1 language, from the file or detected | `en` |
| ✅ `status` | OK, BLOCKED, CUSTOMER_ERROR, UNSUPPORTED or FAILED | `OK` |
| 💵 `billablePages` / `billableOcrPages` | Pages billed for this row (0 for errors and duplicates) | `6` / `0` |

A value the document does not contain stays `null`; nothing is guessed.

### How to convert a PDF to Markdown

1. Click **Try for free** and create a free Apify account if you do not have one.
2. Paste one or more document addresses into **Document URLs** (`documentUrls`), or pick one of your key-value stores in **Your key-value store** (`keyValueStoreId`). The Actor gets read-only access to that store only.
3. Set **Maximum pages per document** (`maxPagesPerDocument`) and turn on **Per-page JSON** (`outputPages`) or **OCR for scanned pages** (`ocr`) if you need them.
4. Click **Start** and wait a few seconds: a 15-page paper takes about one second to convert.
5. Open the **Overview** or **Markdown** tab, or download the dataset as JSON, CSV, Excel or HTML.

Try it free: run with the default input. It converts two public IRS forms, W-9 and W-4 (11 pages), in under a minute.

### How much does it cost to convert PDFs to Markdown?

Pay per event, no start fee. One "Converted page" is one PDF page or PowerPoint slide with text, or 3,000 characters of Markdown for DOCX, XLSX, HTML and text files (they have no fixed pages). A scanned page read with OCR is one "OCR page" instead.

| Event | Free | Starter | Scale | Business |
|---|---:|---:|---:|---:|
| Converted page (per 1,000) | $2.50 | $2.25 | $2.00 | $1.75 |
| OCR page (per 1,000) | $16.00 | $14.40 | $12.80 | $11.20 |

Examples on the Free plan:

- **A 15-page research paper**: 15 converted pages = about $0.04.
- **100 reports of 20 pages**: 2,000 converted pages = about $5.00.
- **A 10-page scanned contract with OCR**: 10 OCR pages = about $0.16.

Never charged: errors, refusals (BLOCKED), unsupported files, empty pages, scanned pages left without OCR, and the same file twice in one run. Set **Maximum cost per run** in the run options: the Actor keeps only the pages that fit, marks the row `truncated: true` and stops cleanly. Apify's free plan gives you monthly platform credits to try it.

### ⬇️ Input

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
  ],
  "maxPagesPerDocument": 200,
  "outputPages": false,
  "extractTables": true,
  "ocr": false
}
```

| Field | What it does | Default |
|---|---|---|
| `documentUrls` | Public PDF, DOCX, PPTX, XLSX, HTML or text addresses | prefilled demo |
| `keyValueStoreId` / `keyValueStoreKeys` | Your own Apify store with files, read-only (all non-JSON records when no key is given) | empty |
| `maxDocuments` | Documents converted at most | 100 |
| `maxPagesPerDocument` | First pages converted per document | 200 |
| `maxFileSizeMb` | Larger files are skipped (CUSTOMER_ERROR, free) | 50 |
| `outputPages` | Adds `pagesData`, one JSON object per page (PDF and PPTX) | false |
| `extractTables` | Ruled PDF tables become Markdown tables | true |
| `pageMarkers` | Adds `<!-- page N -->` before each page | false |
| `ocr` / `ocrLanguage` | Reads scanned pages with Tesseract (eng, fra, deu, spa, ita, por, nld) | false / eng |
| `failRunOnError` | Ends the run FAILED when a document is not converted | false |
| `proxyConfiguration` | Direct connection by default; datacenter or your own proxies allowed | no proxy |

![Input form of PDF & Documents to Markdown with two document URLs](https://api.apify.com/v2/key-value-stores/R1P4OnWyoV0LnGBin/records/pdf-documents-to-markdown-1-input.png)

*Real run nr2Ie0vxRs2zlBzJt · Nov 30, 2026 · two document URLs: an arXiv paper and the IRS Form W-9*

### ⬆️ Output

One dataset row per document (shortened real row):

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "title": "Form W-9 (Rev. March 2024)",
  "format": "pdf",
  "pages": 6,
  "pagesConverted": 6,
  "billablePages": 6,
  "billableOcrPages": 0,
  "characters": 38053,
  "tablesFound": 1,
  "markdown": "Form W-9\n\n(Rev. March 2024)\n\nRequest for Taxpayer ...",
  "metadata": {
    "author": "SE:W:CAR:MP",
    "subject": "Request for Taxpayer Identification Number and Certification",
    "createdAt": "2024-03-06T13:18:13Z",
    "language": "en",
    "languageSource": "document"
  },
  "status": "OK",
  "errorCode": null
}
```

![Output table: PDF, DOCX, PPTX, XLSX and HTML rows, plus BLOCKED, CUSTOMER_ERROR and UNSUPPORTED rows billed 0 pages](https://api.apify.com/v2/key-value-stores/R1P4OnWyoV0LnGBin/records/pdf-documents-to-markdown-2-output.png)

*Real run NrasG4WQpZwljoqwQ · Nov 30, 2026 · 14 inputs: PDF, Word, PowerPoint, Excel, HTML, a robots.txt-disallowed page, a 404, an image, a duplicate file and 3 files from a key-value store*

Rows that could not be converted are kept, free, with a clear code:

| status | When | Charged |
|---|---|---|
| `OK` | Document converted | Yes, per page |
| `BLOCKED` | robots.txt forbids it, HTTP 401 / 403 / 429, CAPTCHA, anti-robot or login page | No |
| `CUSTOMER_ERROR` | Invalid URL, 404, unknown host, file too large, damaged file | No |
| `UNSUPPORTED` | Image, old .doc / .xls / .ppt, password-protected PDF, scanned PDF without OCR | No |
| `FAILED` | Host down or timing out, also after 2 new tries | No |

The run summary (`RUN_SUMMARY` in the key-value store) lists documents by status and code, pages converted and charged, and the stop reason. Rows larger than the 9 MB dataset limit keep a link (`markdownUrl`, `pagesDataUrl`) to the full content in the key-value store.

### Integrations and API

Call the Actor from your code with the official `apify-client` for [Python](https://pypi.org/project/apify-client/) or [Node.js](https://www.npmjs.com/package/apify-client) ([API reference](https://docs.apify.com/api/v2)).

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("badr_xba/pdf-documents-to-markdown").call(run_input={
    "documentUrls": ["https://www.irs.gov/pub/irs-pdf/fw4.pdf"],
    "outputPages": True,
})
for doc in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(doc["title"], doc["pagesConverted"], len(doc["markdown"]))
```

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

const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('badr_xba/pdf-documents-to-markdown').call({
    documentUrls: ['https://www.irs.gov/pub/irs-pdf/fw9.pdf'],
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items[0].markdown.slice(0, 500));
```

- **No-code**: connect it to Make, n8n, Zapier, Google Sheets, Google Drive, Slack or Airbyte.
- **Webhooks**: start your next step (embedding, indexing) when a run finishes.
- **Schedules**: convert a list of reports every day or week.
- **MCP**: use it from Claude, ChatGPT or Cursor through the Apify MCP server.

### Other Actors you may like

- [Website Contact Scraper](https://apify.com/badr_xba/website-contact-scraper): e-mails, phones and social links from company websites.
- [Website Technology Detector](https://apify.com/badr_xba/website-technology-detector): CMS, analytics and tech stack of any website.
- [Ultimate SEO Audit](https://apify.com/badr_xba/ultimate-seo-audit): page-by-page SEO checks.
- [AI Document & Web Analyzer (Claude)](https://apify.com/badr_xba/ai-document-web-analyzer-claude): ask questions about documents and pages with your own Claude key.
- [AI Document & Web Analyzer (OpenAI)](https://apify.com/badr_xba/ai-document-web-analyzer-openai): the same with your own OpenAI key.
- [AI Multimodal Analyzer (Gemini)](https://apify.com/badr_xba/ai-multimodal-analyzer-gemini): images, PDFs and video with your own Gemini key.

### ❓ FAQ

#### Is it legal to convert public PDFs with this Actor?

The Actor only downloads documents that anyone can open without an account, and only when the host's robots.txt allows it. Copyright still applies to the content: check the licence of the documents you convert and how you reuse them. This is not legal advice.

#### What happens if a host blocks a request?

A refusal (HTTP 401, 403 or 429, a CAPTCHA, an anti-robot or login page) gives a `BLOCKED` row, is never charged and is not retried, except a 429 that asks to wait 10 seconds or less (one new try). Network errors, timeouts and HTTP 5xx get at most 2 new tries. The run still succeeds unless you turn on `failRunOnError`.

#### Does it work with scanned PDFs?

Yes, with **OCR for scanned pages** (`ocr: true`). Pages without a text layer are rendered and read with Tesseract, then billed as "OCR page". Without OCR they stay empty, free, and the row says `NO_TEXT_LAYER` or `SCANNED_PAGES`. OCR quality depends on the scan; handwriting is not supported.

#### How fast is it?

Text PDFs convert in about 10-70 ms per page; a 15-page paper takes about one second after download. OCR is much slower: about 12-14 seconds per scanned page with the default 512 MB memory (measured on 37 real scanned pages).

#### Can I use it with Python or through an MCP server?

Yes: see the Python and Node.js examples above, or add the Actor to the Apify MCP server for Claude, ChatGPT or Cursor.

#### Do I need a proxy?

No. The default is a direct connection, which is the cheapest and works for most public hosts. You can choose the Apify datacenter proxy or your own proxies; the residential proxy is not used (it is replaced by the datacenter proxy).

#### Can it read password-protected or login-only documents?

No. Password-protected PDFs return `UNSUPPORTED` (`ENCRYPTED`) and pages behind a login are never opened.

#### Limits

- Not available yet: old binary Office formats (.doc, .xls, .ppt), images (PNG, JPG), handwriting OCR, JavaScript-rendered HTML pages.
- Heading levels in PDFs come from font sizes, so documents that use one font size for everything get paragraphs without headings.
- Tables are detected when they have ruling lines; borderless tables stay as text lines.
- Files up to 50 MB and 2,000 pages per document.

#### Your feedback

Found a document that converts badly, or need a new format? Open an issue in the Issues tab with the URL and what you expected.

Not affiliated with Adobe, Microsoft, arXiv or the IRS. The document names are only used to describe compatibility.

# Actor input Schema

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

Public addresses of PDF, Word (.docx), PowerPoint (.pptx), Excel (.xlsx), HTML or text files. The format is read from the file itself, not from the address. Pages that need a login are never read; each host's robots.txt is respected.

## `keyValueStoreId` (type: `string`):

One of YOUR Apify key-value stores that holds the files to convert (for example files you uploaded). The Actor gets read-only access to this store only.

## `keyValueStoreKeys` (type: `array`):

Keys of the files to convert. Empty = every record of the store that is not JSON (up to "Maximum documents").

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

Documents converted at most in this run.

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

Only the first pages are converted (the row then says truncated: true). For DOCX, XLSX, HTML and text, one page = 3,000 characters of Markdown.

## `maxFileSizeMb` (type: `integer`):

Larger files are not downloaded (CUSTOMER_ERROR, not charged).

## `outputPages` (type: `boolean`):

Add "pagesData": one object per page (text, Markdown, headings, tables, OCR flag). PDF and PPTX only.

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

Turn ruled tables of PDFs into Markdown tables (and arrays in per-page JSON).

## `pageMarkers` (type: `boolean`):

Insert  before each page of a PDF or slide of a PPTX.

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

Read pages that have no text layer (scans) with the open-source Tesseract OCR engine. Charged as "OCR page" instead of "Converted page". Slower.

## `ocrLanguage` (type: `string`):

Main language of the scanned pages.

## `maxConcurrency` (type: `integer`):

Documents downloaded at the same time (conversion itself runs one at a time).

## `failRunOnError` (type: `boolean`):

Off: the run succeeds and errors are listed per row. On: the run ends FAILED when a document could not be converted.

## `proxyConfiguration` (type: `object`):

Default: direct connection. You can choose the Apify datacenter proxy or your own proxies. The residential proxy is not used (it is replaced by the datacenter proxy).

## Actor input object example

```json
{
  "documentUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
  ],
  "maxDocuments": 100,
  "maxPagesPerDocument": 200,
  "maxFileSizeMb": 50,
  "outputPages": false,
  "extractTables": true,
  "pageMarkers": false,
  "ocr": false,
  "ocrLanguage": "eng",
  "maxConcurrency": 2,
  "failRunOnError": false,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `overview` (type: `string`):

Title, format, pages, billed pages, tables, status per document.

## `markdown` (type: `string`):

The Markdown of each document.

## `allFields` (type: `string`):

Every field of every row (JSON, CSV, Excel export).

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

Documents by status, pages converted, billing, stop reason, failed inputs.

# 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",
        "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
    ],
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("badr_xba/pdf-documents-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.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://www.irs.gov/pub/irs-pdf/fw4.pdf",
    ],
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("badr_xba/pdf-documents-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.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://www.irs.gov/pub/irs-pdf/fw4.pdf"
  ],
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call badr_xba/pdf-documents-to-markdown --silent --output-dataset

```

## MCP server setup

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