# Document Text Extractor: PDF, Word, Excel to Markdown (`pipwort/document-text-extractor`) Actor

Turn PDF, DOCX, PPTX, XLSX, HTML, CSV and EPUB files into clean Markdown or plain text, with page counts, metadata and optional RAG-ready chunks. Failed documents are free.

- **URL**: https://apify.com/pipwort/document-text-extractor.md
- **Developed by:** [Pipwort Data](https://apify.com/pipwort) (community)
- **Categories:** AI, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 document extracteds

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

## Document Text Extractor: PDF, Word, Excel to Markdown

Turn documents into clean text your tools and AI models can use. Give it links to PDF, Word, PowerPoint, Excel, HTML, CSV or EPUB files, and get back Markdown or plain text, page counts, metadata and, if you want them, ready-made chunks for embeddings.

**You pay only for documents that convert successfully.** Failed downloads, unsupported files and broken documents are listed with a clear reason and cost nothing.

### Supported files

PDF · DOCX · PPTX · XLSX · XLS · HTML · CSV · JSON · XML · TXT · MD · EPUB

The file type is detected from the file itself, not just the URL, so links without an extension still work.

### What you get for each document

- `markdown` and/or `text`: headings, lists and tables kept as Markdown, or plain text if you prefer
- `pageCount` (PDF pages or PowerPoint slides), `sheetCount` (Excel)
- `title`, `author`, `createdAt`, `producer` where the file includes them
- `wordCount`, `charCount`, `fileSizeBytes`, `sha256` (handy for spotting duplicates)
- `chunks` (optional): text split on paragraph boundaries at your chosen size, with optional overlap
- `pages` (optional): the text of each PDF page separately
- `likelyScanned`: a flag for image-only PDFs, which need OCR (not included)

### Input

| Field | What it does |
|---|---|
| `documentUrls` | Links to the files (required). You can paste a list or upload a text file. |
| `outputFormat` | `markdown` (default), `text` or `both` |
| `chunkSize`, `chunkOverlap` | Turn on chunking for RAG (characters) |
| `includePages` | Add per-page text for PDFs |
| `maxPagesPerDocument` | Read only the first N pages of long PDFs |
| `maxFileSizeMb` | Skip files above this size (default 50 MB) |
| `cleanLayoutNoise` | Remove rotated margin text and stray dots from PDFs (on by default) |

### Example output (shortened)

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "status": "ok",
  "fileType": "pdf",
  "pageCount": 6,
  "title": "Form W-9 (Rev. March 2024)",
  "wordCount": 6257,
  "markdown": "Form  W-9\n\n(Rev. March 2024)\nDepartment of the Treasury ...",
  "chunks": [{ "index": 0, "text": "Form  W-9 ...", "chars": 1187 }]
}
```

A failed document looks like this, and is free:

```json
{ "url": "https://example.com/missing.pdf", "status": "error", "errorType": "http", "error": "HTTP 404 when downloading" }
```

### Pricing

- **US$0.004 per document** converted (includes up to 20 pages or slides)
- **US$0.0002 per extra page** beyond 20, so a 100-page PDF costs US$0.02
- A small start fee of US$0.005 per run

Use `maxPagesPerDocument` or the run's "Maximum cost" setting to keep costs predictable. The Actor stops cleanly at your limit.

### Good to know

- Scanned PDFs (pictures of pages) contain no text layer, so they come back nearly empty with `likelyScanned: true`. OCR is not included.
- Password-protected PDFs are reported as `errorType: encrypted`.
- Text from complex PDF layouts (forms, multiple columns) is extracted in reading order as well as the file allows. It may need light tidying.
- Only process documents you have the right to use. Files are handled in memory during the run and are not stored anywhere else by this Actor.

### Support

If a file converts badly, open an issue with the link (if it's public), and we'll improve the converter.

# Actor input Schema

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

Direct links to the files (PDF, DOCX, PPTX, XLSX, XLS, HTML, CSV, JSON, XML, TXT, MD, EPUB). You can also upload a text file with one URL per line.

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

Markdown keeps headings, lists and tables. Plain text strips formatting.

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

Set above 0 to also return the text split into chunks on paragraph boundaries, ready for embeddings. 0 turns chunking off.

## `chunkOverlap` (type: `integer`):

Characters repeated from the end of the previous chunk.

## `includePages` (type: `boolean`):

Add an array with the text of each PDF page.

## `cleanLayoutNoise` (type: `boolean`):

Remove runs of one-letter lines (rotated margin text) and stray dots that PDF extraction often produces.

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

0 means all pages. Useful to cap cost on very long PDFs.

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

Larger files are skipped with a clear error (not charged).

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

How many files to process at once.

## `requestTimeoutSecs` (type: `integer`):

Per download.

## `conversionTimeoutSecs` (type: `integer`):

Per document.

## `maxRetries` (type: `integer`):

Retries on timeouts, 429 and 5xx responses.

## `userAgent` (type: `string`):

Optional custom User-Agent header for downloads.

## Actor input object example

```json
{
  "documentUrls": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ],
  "outputFormat": "markdown",
  "chunkSize": 0,
  "chunkOverlap": 0,
  "includePages": false,
  "cleanLayoutNoise": true,
  "maxPagesPerDocument": 0,
  "maxFileSizeMb": 50,
  "maxConcurrency": 4,
  "requestTimeoutSecs": 60,
  "conversionTimeoutSecs": 180,
  "maxRetries": 3
}
```

# Actor output Schema

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

One row per document with Markdown/text, metadata and optional chunks. Failed documents have status=error.

# 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": [
        {
            "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("pipwort/document-text-extractor").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": [{ "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("pipwort/document-text-extractor").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": [
    {
      "url": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    }
  ]
}' |
apify call pipwort/document-text-extractor --silent --output-dataset

```

## MCP server setup

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

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/5Gq78mNcbYQZJzjqK/builds/qY1mAE8PSUXq0cF5H/openapi.json
