# Document Extractor — PDF to text, Markdown, tables (`alpinedata/document-extractor`) Actor

Turns PDF URLs into one dataset row per page: plain text, Markdown, tables as row arrays, and an honest has\_text\_layer flag for scanned pages. Built to sit behind any crawler that downloads PDFs but does not read them.

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

## Pricing

from $0.70 / 1,000 page extracteds

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/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Document Extractor — PDF to text, Markdown and tables, one row per page

Give it PDF links, get one dataset row per page: plain text, Markdown, tables as row arrays, and an honest flag for pages that have no text layer. Built to sit behind any crawler that collects PDF links but does not read the files.

### Why one row per page

Most PDF extractors return one blob per file. That is fine for a two-page letter and useless for a 140-page report: you cannot filter, you cannot cite, and a downstream LLM gets the whole thing or nothing. A row per page keeps the page number, the word count and the tables of that page together, so you can pick pages by content, feed them one at a time, or join them back into a document.

### What you get per page

| Field | Content |
|---|---|
| `source_url`, `file_name` | where the page came from |
| `page`, `page_count` | 1-based page number and pages in the file |
| `has_text_layer` | `false` when the page is a scanned image with nothing extractable — reported, not silently empty |
| `text` | plain text as the PDF exposes it |
| `markdown` | text with paragraphs restored, tables appended as Markdown |
| `tables` | list of tables, each a list of rows, each row a list of cell strings |
| `table_count`, `char_count`, `word_count` | page statistics |
| `width`, `height` | page size in PDF points |

A file that cannot be fetched or parsed produces one record with an `error` field and `page: null`, so failures are visible in the same dataset instead of vanishing.

### Input

```json
{
  "pdfUrls": ["https://example.org/report.pdf"],
  "maxPages": 1000,
  "extractTables": true
}
```

**Chaining:** set `datasetId` to the dataset of a previous run and `urlField` to the field that holds the PDF link. The actor reads the links from there — for example from a crawl that collected document URLs.

Limits: `maxFiles` (default 100), `maxPages` across all files (default 1000), `maxFileSizeMb` (default 50). Runs stop before the platform timeout and keep what they have; `RUN_SUMMARY` in the key-value store says whether a limit was hit.

### Limits — read this before you rely on it

- **No OCR.** Scanned pages come back with `has_text_layer: false` and empty text. The flag tells you exactly which pages need OCR; this actor does not run it.
- **Tables are heuristic.** Ruled tables extract well. Whitespace-aligned columns and multi-column layouts can come out merged or split. Check the `tables` field on a sample of your documents before building on it.
- **Encrypted or malformed PDFs** are reported as errors, not repaired.
- **Text order** follows the PDF's internal order. Multi-column pages may interleave.

### Cost

Pure CPU work, no browser. A 30-page text PDF takes a few seconds on 1 GB of memory. Proxy is off by default and only needed if a host blocks datacenter traffic.

# Actor input Schema

## `pdfUrls` (type: `array`):

Direct links to PDF files. Each file becomes one dataset row per page. The prefilled example is a 15-page research paper with tables.

## `datasetId` (type: `string`):

Read the PDF links from a dataset instead — for example the output of Website Content Crawler or any crawler that collected PDF links. Leave empty when using PDF URLs above.

## `urlField` (type: `string`):

Name of the field that holds the PDF link in each dataset record.

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

Stop after this many files.

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

Stop after this many pages across all files. Each page is one result.

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

Detect tables on each page and return them as row arrays plus Markdown.

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

Files larger than this are reported as errors instead of downloaded.

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

Only needed when the PDF host blocks datacenter traffic. Off by default.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "datasetId": "",
  "urlField": "url",
  "maxFiles": 100,
  "maxPages": 1000,
  "extractTables": true,
  "maxFileSizeMb": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `pages` (type: `string`):

One record per PDF page: text, markdown, tables, has\_text\_layer. Failed files appear as records with an error field.

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

Counts of files and pages processed, pages without a text layer, and whether limits were hit.

# 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 = {
    "pdfUrls": [
        "https://arxiv.org/pdf/1706.03762"
    ],
    "urlField": "url",
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("alpinedata/document-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 = {
    "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
    "urlField": "url",
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("alpinedata/document-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 '{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "urlField": "url",
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call alpinedata/document-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alpinedata/document-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/38Vr8Z6PHWUvaMoZx/builds/zPnzqyvI6aEbelTz3/openapi.json
