# PDF to Text Extractor for LLM & RAG (DOCX, PPTX, XLSX) (`digital-tools/document-to-text`) Actor

PDF to text API plus Word (DOCX), PowerPoint (PPTX) and Excel (XLSX) text extraction by URL. Clean, LLM-ready text with headings and tables, page-by-page output, word counts and metadata. Fast, no OCR, ideal for RAG and AI agents. Cheap per document.

- **URL**: https://apify.com/digital-tools/document-to-text.md
- **Developed by:** [凡 方](https://apify.com/digital-tools) (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

### What does Document to Text Extractor do?

**PDF to Text Extractor** pulls **text from PDF, Word (DOCX), PowerPoint (PPTX) and Excel (XLSX) files** by URL. It returns clean, **LLM-ready text** — **DOCX headings as Markdown, Word tables as Markdown tables**, slides with speaker notes, spreadsheet rows as tab-separated text — plus document metadata (title, author, page count) and word counts.

It is a fast, cheap **PDF to text API**, **DOCX to text converter** and **PPTX/XLSX text extractor** for **RAG pipelines, LLM prompts, AI agents, search indexing** and document automation.

### Why use it?

- 📄 **Many formats, one Actor** – PDF, DOCX, PPTX, XLSX, plus HTML, TXT, Markdown, CSV and JSON.
- 📑 **Page-by-page output** – optional `pages` array for PDF pages, slides and sheets, perfect for citations and chunking.
- 🧱 **Structure preserved** – headings, lists and tables from Word documents come out as Markdown.
- 🔐 **Encrypted PDFs** – supply a password if you have one.
- 🕵️ **Scanned PDF detection** – `likelyScanned` flags PDFs with no text layer (OCR is not included).
- ⚡ **Fast and cheap** – no OCR, no browser; a 15-page paper is extracted in about a second.
- 💸 **Pay per document and page** – failed downloads are free.

### How to use it

1. Paste direct file links into **URLs** (up to 50 MB per file).
2. Optionally turn on **Page-by-page output** or limit **Max pages per document**.
3. Click **Start** and read `text` from the dataset, via API or in Make / Zapier / n8n.

#### Input example

```json
{
  "startUrls": [
    { "url": "https://arxiv.org/pdf/1706.03762" },
    { "url": "https://calibre-ebook.com/downloads/demos/demo.docx" }
  ],
  "includePages": true,
  "maxPagesPerDocument": 0
}
```

#### Output example

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileType": "pdf",
  "title": "Attention Is All You Need",
  "totalPages": 15,
  "pagesExtracted": 15,
  "wordCount": 6111,
  "characterCount": 39500,
  "likelyScanned": false,
  "text": "Attention Is All You Need\nAshish Vaswani ...",
  "pages": [{ "page": 1, "text": "..." }],
  "error": null
}
```

### How much does it cost?

This Actor uses **pay-per-event (PPE)** pricing: you pay only for results, and the Apify platform compute it uses is already included.

| Event | Price | Per 1,000 |
|---|---|---|
| Document extracted | **$0.001** per document | **$1.00** per 1,000 documents |
| PDF page or slide extracted | **$0.0002** per PDF page or slide | **$0.20** per 1,000 PDF pages / slides |
| Actor start | $0.0005 per run | – |

Failed downloads and unsupported files are **not charged**. Use **Max pages per document** to cap the cost of very long PDFs. For example, 100 PDFs of 10 pages each cost about **$0.30**. The Actor start fee is charged once per run (one event per GB of memory; the default memory setting counts as one). You can set a **maximum cost per run** in the run options and the Actor stops cleanly when it is reached. Apify's free plan includes $5 of monthly credit, enough to try it at no cost.

### Use cases

- **RAG and AI agents** – turn PDFs, reports, manuals and slide decks into text chunks for embeddings.
- **Document search** – index the text of public reports, filings and research papers.
- **Data extraction** – read tables from Word and Excel files without Office.
- **Content repurposing** – get the text of presentations and whitepapers for summaries and posts.

### Limitations

- No OCR: scanned PDFs (images only) return little or no text and are flagged with `likelyScanned: true`.
- Files must be reachable by a direct public URL. Old binary `.doc`, `.ppt` and `.xls` formats are not supported.

### Other tools by Digital-Tools

- [Webpage to Markdown Converter for LLM & RAG](https://apify.com/Digital-Tools/webpage-to-markdown) – Convert any website or web page URL into clean, LLM-ready Markdown.
- [URL Metadata & Open Graph Link Preview Extractor](https://apify.com/Digital-Tools/url-metadata-extractor) – Bulk extract URL metadata and Open Graph link previews: title, description, og:image, favicon, canonical URL, Twitter Card, RSS feeds and JSON-LD schema.
- [Broken Link Checker - Find 404s & Dead Links](https://apify.com/Digital-Tools/broken-link-checker) – Crawl a website and find broken links, 404s, dead links, 5xx errors, timeouts and redirects.
- [Chinese Simplified/Traditional Converter & Pinyin Toolkit](https://apify.com/Digital-Tools/chinese-text-toolkit) – Bulk convert Simplified and Traditional Chinese (Taiwan and Hong Kong variants, with phrase conversion), generate pinyin with tones or initials, segment Chinese words and extract keywords.
- [Sitemap URL Extractor - Get All URLs from sitemap.xml](https://apify.com/Digital-Tools/sitemap-url-extractor) – Extract every URL from a website sitemap.xml.
- [RSS to JSON Feed Reader - Parse RSS & Atom](https://apify.com/Digital-Tools/rss-feed-reader) – RSS to JSON API: read RSS, Atom and RDF feeds in bulk and get clean JSON (title, link, date, author, categories, summary, full content, images and podcast enclosures).
- [Bulk SSL Certificate Checker & DNS Lookup](https://apify.com/Digital-Tools/ssl-dns-checker) – Bulk SSL certificate expiry checker and DNS lookup for many domains at once: expiry date, days left, issuer, SANs, TLS version and validity, plus A, AAAA, CNAME, MX, NS, TXT, CAA, SOA, SPF and DMARC.
- [URL Status & Redirect Chain Checker](https://apify.com/Digital-Tools/url-status-redirect-checker) – Bulk HTTP status code and redirect chain checker.
- [HTML Table Extractor - Tables to CSV & JSON](https://apify.com/Digital-Tools/html-table-extractor) – Extract HTML tables from any web page to CSV and JSON.

Questions or feature requests? Open an issue in the **Issues** tab.

# Actor input Schema

## `startUrls` (type: `array`):

Direct links to PDF, Word (DOCX), PowerPoint (PPTX), Excel (XLSX), HTML or text files to extract text from (max 50 MB each). PDF to text for LLM and RAG.

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

Also return a 'pages' array with the text of each PDF page, PowerPoint slide or Excel sheet (useful for citations and chunking in RAG).

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

Only extract the first N PDF pages, slides or sheets (0 = all). Limits cost for very long PDFs.

## `maxCharacters` (type: `integer`):

Truncate the extracted text to this many characters (0 = no limit). Useful for LLM context windows.

## `pdfPassword` (type: `string`):

Password for encrypted PDFs (optional). Leave empty for unlocked files.

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

How many documents to download and extract in parallel.

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

Timeout in seconds for each file download.

## Actor input object example

```json
{
  "startUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    },
    {
      "url": "https://calibre-ebook.com/downloads/demos/demo.docx"
    }
  ],
  "includePages": false,
  "maxPagesPerDocument": 0,
  "maxCharacters": 0,
  "maxConcurrency": 5,
  "timeoutSecs": 60
}
```

# Actor output Schema

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

Dataset with one item per result.

# 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 = {
    "startUrls": [
        {
            "url": "https://arxiv.org/pdf/1706.03762"
        },
        {
            "url": "https://calibre-ebook.com/downloads/demos/demo.docx"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("digital-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 = { "startUrls": [
        { "url": "https://arxiv.org/pdf/1706.03762" },
        { "url": "https://calibre-ebook.com/downloads/demos/demo.docx" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("digital-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 '{
  "startUrls": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    },
    {
      "url": "https://calibre-ebook.com/downloads/demos/demo.docx"
    }
  ]
}' |
apify call digital-tools/document-to-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,digital-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/2OOI381Co3Do0oQuZ/builds/CnF8IJj2oC3XKQFKF/openapi.json
