# PDF & DOCX to Text, Markdown & Tables - OCR for Scanned PDFs (`michail-data-tools/document-to-text`) Actor

Convert PDF, scanned PDF, DOCX and TXT URLs to clean text and LLM-ready Markdown. Tables become Markdown tables, scanned pages are OCR'd in 23 languages. Per-page output and metadata. Pay per document.

- **URL**: https://apify.com/michail-data-tools/document-to-text.md
- **Developed by:** [Michail](https://apify.com/michail-data-tools) (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.40 / 1,000 documents converted

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

**Give it PDF, scanned PDF or DOCX links → get clean text and LLM-ready Markdown, with tables kept as tables.**
OCR in 23 languages, only where a page has no text layer. **$0.002 per document** (+$0.002 per OCR page), failed files are free, no subscription.

📖 Step-by-step guide: [Turn PDFs (even scanned ones) into clean Markdown for RAG in one API call](https://dev.to/kolesnichenko575boop/turn-pdfs-even-scanned-ones-into-clean-markdown-for-rag-in-one-api-call-18d2) · 💻 Code examples: [GitHub](https://github.com/kolesnichenko575-boop/podcast-transcript-api-examples)

### What does Document to Text do?

**Document to Text** converts **PDF, scanned PDF, DOCX and TXT** files into clean, structured text — ready for search, analysis and AI. Give it document URLs and get back:

- 📝 **Clean plain text** — hyphenation and broken line wraps fixed, paragraphs preserved
- 🤖 **LLM-ready Markdown** — headings, lists and **tables converted to Markdown tables**
- 📄 **Per-page content** for PDFs, with a flag for pages that needed OCR
- 🔎 **OCR for scanned pages** in 23 languages — applied only where a page has no text layer
- 🏷️ **Metadata** — title, author, page count, word count

### Why use it?

- 💸 **Cheap and fair** — pay per document, plus a small fee only for pages that actually needed OCR. Failed downloads and unsupported files are **never charged**.
- 🧠 **Built for AI pipelines** — Markdown output with real tables is what LLMs and RAG systems understand best.
- 🖨️ **Handles scans** — invoices, contracts and old reports without a text layer are OCR'd automatically.
- ⚡ **Fast** — text PDFs are parsed in seconds; many documents are processed in parallel.
- 🛡️ **Respects your budget** — the Actor stops before exceeding your *Max cost per run*.

### What can I use it for?

- **RAG and chatbots** — turn PDFs and Word files into Markdown chunks for your vector database.
- **Document processing** — extract text from invoices, contracts, reports and forms.
- **Research** — convert papers and reports into searchable text.
- **Data extraction** — pull tables out of PDFs as Markdown or tab-separated text.
- **Archiving and compliance** — make scanned archives searchable.

### How to use it

1. Click **Try for free**.
2. Paste document URLs (direct links to `.pdf`, `.docx` or `.txt` files).
3. Choose output formats and, for scanned documents, the OCR languages.
4. Click **Start** and download results as JSON, CSV, Excel or HTML — or get them via the API.

### How much does it cost?

Pay-per-event pricing (see the *Pricing* tab):

- **Document processed** — a small fixed price per successfully converted file.
- **OCR page** — charged only for pages without a text layer that had to be OCR'd.

A 30-page text PDF costs one document event. A 10-page scanned PDF costs one document event plus 10 OCR pages. Apify platform usage is included.

### Input example

```json
{
  "urls": [
    { "url": "https://arxiv.org/pdf/1706.03762" },
    { "url": "https://example.com/contract.docx" }
  ],
  "outputFormats": ["text", "markdown"],
  "ocr": "auto",
  "ocrLanguages": ["eng"],
  "extractTables": true
}
```

### Output example (real test run)

From a real test run on `https://arxiv.org/pdf/1706.03762` (long fields shortened, nothing else edited):

```json
{
  "status": "ok",
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileType": "pdf",
  "fileName": "1706.03762",
  "sizeBytes": 2215244,
  "pageCount": 15,
  "processedPages": 15,
  "ocrPages": 0,
  "metadata": {
    "Author": "",
    "CreationDate": "D:20240410211143Z",
    "Creator": "LaTeX with hyperref",
    "Producer": "pdfTeX-1.40.25",
    "Subject": "",
    "Title": ""
  },
  "charCount": 41099,
  "wordCount": 6343,
  "text": "Provided proper attribution is provided, Google hereby grants permission to\nreproduce the tables and figures in this paper solely for use in...",
  "markdown": "Provided proper attribution is provided, Google hereby grants permission to reproduce the tables and figures in this paper solely for use in...",
  "processingSeconds": 2.1
}
```

Items that could not be processed are returned with `"status": "error"` and a clear `error` message — and are not charged.

### Tips

- **OCR languages**: choose only the languages you need — fewer languages means faster and more accurate OCR.
- **Large PDFs**: use *Max pages per PDF* to process only the first pages.
- **Web pages are not documents**: for HTML pages use a website crawler; this Actor needs a direct file link.
- **Integrations**: connect it to Google Drive, Make, Zapier, n8n or LangChain via the Apify API.

### FAQ

**Which file types are supported?**
PDF (text and scanned), DOCX and plain text files. Password-protected PDFs are not supported.

**How accurate is OCR?**
Very good for clean scans and printed text. Handwriting and low-quality photos give weaker results.

**Something does not work?**
Open an issue in the **Issues** tab with the document URL. We fix reported problems quickly.

### Integrations & API

Run it from **Make, n8n, Zapier**, Google Sheets, webhooks or your own code — results come back as clean JSON.

**Python**

```python
from apify_client import ApifyClient
client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("michail-data-tools/document-to-text").call(run_input={...})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**AI agents (MCP):** add this tool to Claude, Cursor or any MCP client via the Apify MCP server — `https://mcp.apify.com?tools=michail-data-tools/document-to-text` — and let your agent call it directly.

### More tools from the same developer

- [Viral Video Breakdown AI](https://apify.com/michail-data-tools/viral-video-breakdown) — hook score, structure and a reusable script from any TikTok
- [TikTok Transcript](https://apify.com/michail-data-tools/tiktok-transcript) — video to text, SRT and AI summary
- [Podcast & Audio Transcriber](https://apify.com/michail-data-tools/podcast-audio-transcriber) — RSS, MP3 and any audio URL to text
- [Image to Text OCR](https://apify.com/michail-data-tools/image-to-text-ocr) — photos, screenshots and scans to text
- [Company Jobs Scraper](https://apify.com/michail-data-tools/company-jobs-scraper) — all open jobs from Greenhouse, Lever, Ashby and more

Found a problem or need a feature? Open an issue — we usually reply within a day. If the tool saved you time, a short review helps others find it.

# Actor input Schema

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

Direct links to PDF, DOCX or TXT files. Scanned PDFs are supported via OCR.

## `outputFormats` (type: `array`):

What to include in each result.

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

auto = OCR only pages without a text layer (recommended). always = OCR every page. never = text layer only.

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

Languages used for OCR. Pick the languages of your scanned documents (more languages = slower).

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

Detect tables in PDFs and output them as Markdown tables.

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

Process only the first N pages of each PDF. 0 = all pages.

## `concurrency` (type: `integer`):

How many documents to process at the same time (1-8).

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "outputFormats": [
    "text",
    "markdown"
  ],
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "extractTables": true,
  "maxPages": 0,
  "concurrency": 3
}
```

# Actor output Schema

## `documents` (type: `string`):

One item per document: text, Markdown, per-page content, metadata.

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

// Run the Actor and wait for it to finish
const run = await client.actor("michail-data-tools/document-to-text").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": [{ "url": "https://arxiv.org/pdf/1706.03762" }] }

# Run the Actor and wait for it to finish
run = client.actor("michail-data-tools/document-to-text").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": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ]
}' |
apify call michail-data-tools/document-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,michail-data-tools/document-to-text"
        }
    }
}
```

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/4AvKMbe8XdKdnXuEL/builds/VfBRvfMUy3jVJglKj/openapi.json
