# PDF & Word to Markdown / Text Converter (PDF, DOCX, HTML, TXT) (`dailypalslab/pdf-docx-to-markdown`) Actor

Convert PDF, Word DOCX, HTML and TXT files from any URL into clean Markdown or plain text for LLMs, RAG and search. Gets title, author, dates, page and word counts, splits by page, and flags scanned PDFs.

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

## Pricing

Pay per event

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

## PDF, Word & Image to Markdown / Text Converter with OCR

Convert **PDF, Word (DOCX), HTML, TXT and image files (PNG, JPEG, WEBP, TIFF) to clean Markdown or plain text** from any URL. **Built-in OCR** reads scanned PDFs, photographed documents and screenshots. Get the full text plus **title, author, created/modified dates, page count, word count and OCR confidence** as structured JSON, ready for **LLMs, RAG pipelines, vector databases, search indexes and data analysis**.

No browser, no separate OCR service, no setup: paste file links, click Start, download JSON, CSV or Excel, or call it from the API.

### What does this document converter do?

- 📄 **PDF to Markdown / text**: keeps headings (detected from font size), paragraphs, bullet lists, and joins words hyphenated across lines.
- 📝 **DOCX to Markdown**: headings, bold/italic, lists, **tables** (as GFM Markdown tables), links, footnotes.
- 🌐 **HTML to Markdown**: strips navigation, headers, footers, scripts and styles; keeps the main content.
- 📃 **TXT / Markdown** files are passed through as-is.
- 🏷️ **Metadata**: title, author, subject, keywords, creator app, created and modified dates, language, page count, word and character counts.
- ✂️ **Split by page**: one result per PDF page for chunking and page-level citations, or page markers inside a single document.
- 🔍 **OCR for scanned PDFs**: pages without a text layer are detected and run through OCR automatically (Tesseract engine, 60+ languages). Normal PDFs are not OCR'd, so you only pay for OCR where it is needed.
- 🖼️ **Image to text**: PNG, JPEG, WEBP, TIFF and BMP images (screenshots, photos of documents, receipts, scans) become Markdown text.
- 🔗 **Share links work**: Google Drive, Google Docs (exported as DOCX) and Dropbox links are turned into direct downloads automatically.
- 📦 **Bulk**: up to 1,000 files per run, several in parallel.

### Use cases

- **AI and RAG**: turn PDF manuals, contracts, reports and research papers into Markdown chunks for embeddings and chatbots.
- **Search and knowledge bases**: index the text of document libraries, policies and help-center files.
- **Data extraction**: pull text from government forms, filings, invoices or academic papers for analysis.
- **Content migration**: move Word documents into a CMS, wiki, Notion or static site as Markdown.
- **Scanned archives**: make old scanned letters, forms, books and records searchable.
- **Screenshots and photos**: pull text out of app screenshots, slides, whiteboard photos and receipts.
- **Document audits**: list titles, authors, dates, page counts, and find which files are scans.

### How to use it

1. Add file URLs (one per line). They must be reachable without a login.
2. Choose **Markdown** or **Plain text**, and whether you want one row per document or per page.
3. Click **Start** and download the results in JSON, CSV, Excel, HTML or XML, or use the API.

**Uploading your own files**: put them in an Apify key-value store (Storage → Key-value stores → upload a record) and use the record URL, e.g. `https://api.apify.com/v2/key-value-stores/<storeId>/records/<key>`. Records in your own stores are read with your run's token, so private stores work too.

### OCR (scanned PDFs and images)

| `ocr` | What happens |
| --- | --- |
| `auto` (default) | PDF pages with almost no text (under 50 characters) that contain an image are OCR'd, and so are all near-empty pages of a document that looks scanned. Image files are OCR'd. Born-digital PDFs are **not** OCR'd. |
| `always` | Every page is rendered and OCR'd, and the OCR text replaces the text layer. Use it for PDFs whose text layer is garbled (broken fonts, copy-paste gives gibberish). |
| `off` | No OCR. Image files return an error row; scanned PDFs are only flagged with `likelyScanned: true`. |

- **Languages**: set `ocrLanguages` to Tesseract codes, e.g. `["eng"]`, `["deu"]`, `["eng", "fra"]`, `["chi_sim"]`, `["jpn"]`, `["ara"]` (2-letter codes like `de` work too; up to 5). English is built in; other languages are downloaded once per run.
- **Quality**: PDF pages are rendered at about 220 DPI. Each OCR'd row has `ocrUsed: true`, `ocrPages` and `ocrConfidence` (0-100). Clean scans and screenshots usually score 85-95; under 60 the row gets a hint (blurry, skewed, handwritten or wrong language).
- **Limits**: `maxOcrPages` (default 30) caps OCR pages per document; pages beyond it are listed in the hint. Handwriting, very low-resolution faxes and complex tables OCR poorly. Multi-page TIFFs: only the first page is read.
- **Speed**: about 1-3 seconds per page at 4 GB memory (one CPU core); give the run more memory to OCR big batches faster (one OCR worker per 4 GB).

### Input example

```json
{
    "fileUrls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://arxiv.org/pdf/1706.03762",
        "https://calibre-ebook.com/downloads/demos/demo.docx",
        "https://example.com/scans/contract-scan.pdf",
        "https://example.com/screenshots/invoice.png"
    ],
    "outputFormat": "markdown",
    "ocr": "auto",
    "ocrLanguages": ["eng"],
    "maxOcrPages": 30,
    "splitByPage": false,
    "includePageBreaks": true,
    "maxPages": 50,
    "maxFileSizeMb": 25
}
```

| Field | What it does | Default |
| --- | --- | --- |
| `fileUrls` | Links to PDF, DOCX, HTML, TXT or image files | required |
| `outputFormat` | `markdown` or `text` | `markdown` |
| `splitByPage` | One row per PDF page | `false` |
| `includePageBreaks` | Page markers between PDF pages | `false` |
| `includePerPage` | Add a `perPage` array to each document row | `false` |
| `ocr` | `auto`, `always` or `off` | `auto` |
| `ocrLanguages` | Tesseract language codes | `["eng"]` |
| `maxOcrPages` | OCR pages per document (1–500) | `30` |
| `maxPages` | Pages per document (1–500) | `50` |
| `maxFileSizeMb` | Skip larger files (1–100 MB) | `25` |
| `maxFiles` | Files per run (hard cap 1000) | `100` |
| `timeoutSecs` | Download timeout | `60` |
| `maxConcurrency` | Files in parallel (1–5) | `3` |

### Output example

```json
{
    "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "fileName": "fw9.pdf",
    "fileType": "pdf",
    "bytes": 140815,
    "pages": 6,
    "pagesProcessed": 6,
    "truncated": false,
    "title": "Form W-9 (Rev. March 2024)",
    "author": "SE:W:CAR:MP",
    "subject": "Request for Taxpayer Identification Number and Certification",
    "createdAt": "2024-03-06T13:18:13.000Z",
    "modifiedAt": "2024-03-06T13:18:13.000Z",
    "language": "en-US",
    "wordCount": 6390,
    "charCount": 38134,
    "markdown": "# Form W-9(Rev. March 2024)\n\n## Request for Taxpayer Identification Number and Certification\n\nDepartment of the Treasury Internal Revenue Service ...",
    "likelyScanned": false,
    "ocrUsed": false,
    "ocrPages": 0,
    "ocrConfidence": null,
    "hint": null,
    "error": null,
    "processedAt": "2026-11-22T04:57:03.209Z"
}
```

A scanned PDF row looks the same with `"likelyScanned": true, "ocrUsed": true, "ocrPages": 2, "ocrConfidence": 95`. Image files have `fileType` `png`, `jpeg`, `webp`, `tiff` or `bmp` and `pages: 1`.

With `splitByPage: true`, each row also has `page` and holds only that page's content. With `outputFormat: "text"`, the content field is `text` instead of `markdown`. Files that fail (404, too large, unsupported type, password-protected) get a row with `error` filled in. A run summary is saved as the `SUMMARY` record.

### Pricing

This Actor uses **pay-per-event** pricing. You pay per converted document, and long documents add a small per-page fee:

| Event | Price |
| --- | --- |
| `document`: each successfully converted file (includes the first 10 pages) | **$0.003 per document** |
| `extra-page`: each page beyond 10 in a document | **$0.0005 per page** |
| `ocr-page`: each page or image that was OCR'd (on top of the above) | **$0.006 per page** |

- **No charge** for files that fail (404, too large, unsupported, unreadable).
- For DOCX the page count from the file is used; for DOCX without one, HTML and TXT, one page = 3,000 characters of text.
- `maxPages` caps the pages (and cost) per document; `maxOcrPages` caps the OCR pages.
- Normal PDFs, Word, HTML and TXT files are never charged for OCR in `auto` mode.
- Platform usage (compute) is included in the event prices.
- Set **Max cost per run** in the run options and the Actor stops before going over it, processing fewer pages or files if needed.

Example: 100 PDFs of 8 pages = 100 × $0.003 = **$0.30**. One 60-page PDF = $0.003 + 50 × $0.0005 = **$0.028**. A 5-page scanned PDF = $0.003 + 5 × $0.006 = **$0.033**. 100 screenshots = 100 × ($0.003 + $0.006) = **$0.90**.

### Limits

- Up to 1,000 files per run, 100 MB per file, 500 pages per document.
- OCR quality depends on the scan: handwriting, heavy noise, skewed photos and tiny text give lower confidence. Multi-column scans come out in Tesseract's reading order.
- Complex PDF layouts (multi-column papers, forms, tables) are extracted in reading order as well as the text layer allows; PDF tables become plain lines, not Markdown tables.
- Legacy Word `.doc`, `.xlsx`, `.pptx` and password-protected PDFs are not supported.
- Files behind a login, CAPTCHA or bot protection can't be downloaded. Some sites block automated downloads; host the file elsewhere or upload it to a key-value store.

### FAQ

**Is the Markdown good for LLMs and RAG?**
Yes. Headings, lists and tables are kept so chunkers can split on structure. Use `splitByPage` for page-level chunks with page numbers for citations.

**Can it convert scanned PDFs?**
Yes. With `ocr: "auto"` (the default) pages without a text layer are OCR'd and you pay $0.006 per OCR'd page. Text PDFs are read directly and not OCR'd.

**Can it extract text from images and screenshots?**
Yes: PNG, JPEG, WEBP, TIFF and BMP links are OCR'd into Markdown text, one row per image.

**Which OCR languages are supported?**
60+ Tesseract languages, including English, German, French, Spanish, Italian, Portuguese, Dutch, Polish, Russian, Ukrainian, Turkish, Arabic, Hebrew, Hindi, Chinese (simplified and traditional), Japanese and Korean. Set `ocrLanguages`; mixing 2-3 languages works but is slower.

**How accurate is the OCR?**
On clean scans and screenshots we measured 100% word accuracy with confidence 95. Old, noisy or skewed scans score lower; check `ocrConfidence` and the hint.

**My PDF has text but it comes out as gibberish.**
Its text layer uses broken font encodings. Set `ocr: "always"` to ignore the text layer and OCR the rendered pages.

**How do I convert a Google Doc?**
Paste the share link (`https://docs.google.com/document/d/.../edit`). The doc must be shared as "Anyone with the link"; it is exported as DOCX and converted.

**What about Google Drive or Dropbox files?**
Paste the share link; it is turned into a direct download link automatically. The file must be publicly shared.

**Can I get only the metadata?**
Yes, set `maxPages` to 1 to read metadata and the first page cheaply; `pages` still shows the full page count for PDFs.

**Is there an API?**
Yes. Start runs and fetch results with the Apify API, the JavaScript or Python client, or the CLI, or connect Make, Zapier, n8n, LangChain or LlamaIndex.

### Is it legal to convert these documents?

The Actor only processes files at the URLs you provide. **You are responsible for having the right to download, process and store those files and their contents**, including copyright, confidentiality, privacy (e.g. GDPR) and the source website's terms. Don't submit documents with personal data unless you have a legal basis to process it. If in doubt, ask a lawyer.

### Support

Missing a file type or found a conversion problem? Open an issue on the Actor's **Issues** tab with the file URL. Made by **Daily Pals Labs**.

# Actor input Schema

## `fileUrls` (type: `array`):

Direct links to PDF, Word (.docx), HTML, TXT/Markdown files, or images (PNG, JPEG, WEBP, TIFF, BMP) to OCR. Google Drive, Google Docs and Dropbox share links are converted automatically. Files uploaded to an Apify key-value store work too (use the record URL).

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

Markdown keeps headings, lists, tables and links (best for LLMs and RAG). Plain text strips all formatting.

## `splitByPage` (type: `boolean`):

Output one dataset row per PDF page instead of one per document. Handy for chunking and page citations.

## `includePageBreaks` (type: `boolean`):

Insert a page marker between PDF pages ("---" +  in Markdown, "--- Page N ---" in text).

## `includePerPage` (type: `boolean`):

Also add a perPage array (page number, word count, content) to each document row.

## `ocr` (type: `string`):

Auto: OCR only PDF pages that have no usable text layer (scans, image-only pages) plus image files; normal PDFs are not OCR'd. Always: OCR every page, ignoring the text layer (for PDFs with broken or garbled text). Off: never OCR. Each OCR'd page is billed as an ocr-page event.

## `ocrLanguages` (type: `array`):

Languages in the documents, as Tesseract codes: eng, deu, fra, spa, ita, por, nld, pol, rus, ukr, tur, ara, heb, hin, jpn, kor, chi_sim, chi_tra and more (2-letter codes like de or fr work too). Up to 5; more languages are slower. English is built in, others download once per run.

## `maxOcrPages` (type: `integer`):

OCR at most this many pages per document (1-500); further pages that need OCR are skipped and reported in the hint. Caps the ocr-page cost.

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

Stop after this many pages (1-500). For DOCX/HTML/TXT, one page = 3,000 characters.

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

Skip files larger than this (1-100).

## `maxFiles` (type: `integer`):

Process at most this many URLs (hard cap 1000).

## `timeoutSecs` (type: `integer`):

Give up on a single file after this many seconds (download + conversion).

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

1-5. Use 1024 MB+ memory for 4-5 large PDFs at once.

## Actor input object example

```json
{
  "fileUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "outputFormat": "markdown",
  "splitByPage": false,
  "includePageBreaks": false,
  "includePerPage": false,
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxOcrPages": 30,
  "maxPages": 50,
  "maxFileSizeMb": 25,
  "maxFiles": 100,
  "timeoutSecs": 60,
  "maxConcurrency": 3
}
```

# Actor output Schema

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

Converted documents as a dataset (JSON, CSV, Excel via the API).

## `summary` (type: `string`):

Counts, failures and settings for this run.

# 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 = {
    "fileUrls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dailypalslab/pdf-docx-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 = { "fileUrls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://arxiv.org/pdf/1706.03762",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("dailypalslab/pdf-docx-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 '{
  "fileUrls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call dailypalslab/pdf-docx-to-markdown --silent --output-dataset

```

## MCP server setup

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