# PDF to Markdown & Text Extractor — Fast AI & RAG (`alias_md5/pdf-markdown-extractor`) Actor

Batch-convert digital PDF URLs into clean Markdown, plain text, per-page output, and structured metadata for AI, LLMs, and RAG pipelines. Priced from $1.00 down to $0.50 per 1,000 PDFs — broken links and image-only scans are skipped automatically at $0.

- **URL**: https://apify.com/alias_md5/pdf-markdown-extractor.md
- **Developed by:** [Alias Data Studio](https://apify.com/alias_md5) (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 $0.60 / 1,000 pdf 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.
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

## PDF to Markdown & Text Extractor — Fast AI & RAG

Turn batches of **digital PDF URLs** into clean **Markdown**, **plain text**, **per-page chunks**, and structured **document metadata** in seconds — purpose-built for **AI agents, LLM ingestion, RAG knowledge bases, and document search indexing**. Export directly as **JSON, CSV, Excel, XML, or RSS**.

### Why Choose PDF to Markdown & Text Extractor?

- **Built for AI & RAG speed at a fraction of the cost** — batch-extracts digital PDFs (research papers, whitepapers, SEC filings, technical docs, manuals, contracts, and policy reports) at **$1.00 down to $0.50 per 1,000 extracted PDFs**, up to 5–10x cheaper than heavy OCR-first parsers.
- **Clean, chunk-ready Markdown & per-page output** — automatically detects headings, reflows hard-wrapped paragraphs, repairs hyphenated line breaks, normalizes bullet/numbered lists, and optionally emits a structured `pages` array (`pageNumber`, `text`, `markdown`, `characterCount`) with exact `startPage` / `endPage` slicing.
- **Rich document metadata out of the box** — captures `title`, `author`, `subject`, UTC `createdAtIso`, `fileName`, `fileSizeBytes`, `pageCount`, `extractedPageCount`, `wordCount`, and `characterCount` for every document.
- **Zero charge for broken links or image-only scans** — 404 errors, HTML pages, password-protected files, corrupted documents, oversized files, and scanned image-only PDFs (`no_text_layer`) are detected and skipped automatically at **$0 cost** while valid PDFs in the same batch finish without interruption.
- **Automatic batch hygiene & `RUN_SUMMARY`** — deduplicates URLs, enforces per-file size (up to 50 MB) and timeout caps, redacts query secrets, and saves a concise `RUN_SUMMARY` report in Key-Value Storage.

### Ideal Use Cases

- **RAG & AI knowledge bases** — convert ArXiv papers, product manuals, API specifications, and industry whitepapers into clean Markdown ready for chunking and vector embeddings.
- **Financial, legal & regulatory pipelines** — batch-extract text, page ranges, and metadata from public filings, standards specifications, and compliance bulletins at ultra-low cost.
- **Enterprise search indexing** — load normalized titles, authors, timestamps, and full text into Elasticsearch, OpenSearch, PostgreSQL, Qdrant, or Pinecone.
- **AI Agent tooling (MCP & n8n)** — connect directly to Claude, Cursor, or n8n workflows to read and summarize linked PDFs on demand.

### Pricing

Pay only for successfully extracted PDFs saved to your dataset — failed URLs and image-only scanned PDFs always cost **$0**:

| Apify Plan | Price per 1,000 PDFs | Price per PDF |
| --- | ---: | ---: |
| Free | $1.00 | $0.00100 |
| Starter (Bronze) | $0.85 | $0.00085 |
| Scale (Silver) | $0.70 | $0.00070 |
| Business (Gold) | $0.60 | $0.00060 |
| Enterprise (Platinum / Diamond) | $0.50 | $0.00050 |

### Input Example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762",
    "https://arxiv.org/pdf/2005.11401"
  ],
  "outputFormat": "both",
  "startPage": 1,
  "endPage": 5,
  "shouldIncludePages": true
}
```

#### Input Parameters

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `pdfUrls` | `string[]` | *(required)* | Direct public HTTP or HTTPS URLs pointing to digital PDF files. Duplicate URLs are automatically deduplicated. |
| `outputFormat` | `"both" \| "markdown" \| "text"` | `"both"` | Choose clean Markdown, plain text, or both. Selecting `"markdown"` keeps dataset rows compact for RAG pipelines. |
| `shouldIncludePages` | `boolean` | `false` | When `true`, adds a `pages` array with per-page `pageNumber`, `text`, `markdown`, and `characterCount`. |
| `startPage` | `integer \| null` | `1` | Optional 1-based inclusive starting page number. |
| `endPage` | `integer \| null` | *(last page)* | Optional 1-based inclusive ending page number. |
| `maxFileSizeMegabytes` | `integer` | `50` | Maximum allowed file size per PDF (1–50 MB). Larger files are skipped safely at $0. |
| `requestTimeoutSeconds` | `integer` | `30` | Maximum download timeout per PDF (5–120 seconds). |

### Output Example

Each successfully extracted PDF produces one structured item in your default dataset:

```json
{
  "sourceUrl": "https://arxiv.org/pdf/1706.03762",
  "fileName": "1706.03762v7.pdf",
  "fileSizeBytes": 2215244,
  "pageCount": 15,
  "extractedPageCount": 5,
  "wordCount": 2418,
  "characterCount": 15482,
  "title": "Attention Is All You Need",
  "author": "Ashish Vaswani et al.",
  "subject": "Computation and Language",
  "createdAtIso": "2024-04-10T21:11:43Z",
  "fullText": "Attention Is All You Need...",
  "markdown": "## Attention Is All You Need\n\n#### Abstract\n\nThe dominant sequence transduction models...",
  "pages": [
    {
      "pageNumber": 1,
      "text": "Attention Is All You Need...",
      "markdown": "## Attention Is All You Need...",
      "characterCount": 3120
    }
  ]
}
```

### Quick Integration: Python, Node.js, MCP & n8n

#### Python (`apify-client`)

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("alias_md5/pdf-markdown-extractor").call(run_input={
    "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
    "outputFormat": "markdown",
    "shouldIncludePages": True,
})
for doc in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(doc["title"], doc["wordCount"], len(doc.get("pages", [])))
```

#### Node.js (`apify-client`)

```javascript
import { ApifyClient } from "apify-client";

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor("alias_md5/pdf-markdown-extractor").call({
  pdfUrls: [
    "https://arxiv.org/pdf/1706.03762",
    "https://arxiv.org/pdf/2005.11401",
  ],
  outputFormat: "markdown",
  shouldIncludePages: true,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((d) => ({ title: d.title, words: d.wordCount })));
```

#### AI Agents (Apify MCP Server)

Give Claude Desktop, Cursor, or any MCP-compatible AI agent direct PDF-to-Markdown reading capabilities:

```json
{
  "mcpServers": {
    "apify": {
      "url": "https://mcp.apify.com/?actors=alias_md5/pdf-markdown-extractor",
      "headers": {
        "Authorization": "Bearer <YOUR_APIFY_TOKEN>"
      }
    }
  }
}
```

#### n8n Workflow (Automated RAG Ingestion)

1. Trigger on new PDF URLs from RSS, Google Drive, Slack, or a webhook.
2. Add the official **Apify** node (`@apify/n8n-nodes-apify`) → **Run Actor** with `alias_md5/pdf-markdown-extractor` (`outputFormat: "markdown"`, `shouldIncludePages: true`).
3. Chain **Get Dataset Items** directly into your vector store node (Pinecone, Qdrant, Supabase, or PostgreSQL `pgvector`) or an LLM summarization step.

### Batch Summary (`RUN_SUMMARY`)

At the end of every run, a compact JSON report is saved to Key-Value Storage under the key `RUN_SUMMARY`:

```json
{
  "requestedUrlCount": 8,
  "uniqueUrlCount": 8,
  "succeededCount": 6,
  "failedCount": 2,
  "skippedDueToBudgetCount": 0,
  "chargedEventCount": 6,
  "totalExtractedPageCount": 140,
  "totalWordCount": 59962,
  "elapsedMilliseconds": 2377,
  "failedTargets": [
    {
      "sourceUrl": "https://arxiv.org/pdf/9999.99999-nonexistent-audit-test.pdf",
      "failureCode": "http_error",
      "reason": "HTTP request returned status 404."
    },
    {
      "sourceUrl": "https://www.w3.org/",
      "failureCode": "non_pdf_content",
      "reason": "Downloaded content is not a valid PDF document (missing %PDF- header)."
    }
  ]
}
```

### Supported Documents & FAQ

- **Which PDFs work best?** Digital PDFs with an embedded text layer — including academic papers (ArXiv), financial filings, whitepapers, technical manuals, contracts, invoices, and policy reports.
- **What happens if my batch contains scanned image-only PDFs?** Because this Actor prioritizes ultra-fast native text extraction without running heavy visual OCR, any image-only PDF without a text layer is automatically detected, skipped cleanly with reason `no_text_layer` in `RUN_SUMMARY`, and billed **$0**. You can easily route only those flagged `no_text_layer` URLs to a dedicated visual OCR step while saving 80–90% on all digital PDFs.
- **Can I extract only the first few pages of long documents?** Yes — set `startPage` and `endPage` (1-based inclusive) to extract specific page windows such as abstracts, executive summaries, or tables of contents.

# Actor input Schema

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

List of direct public HTTP or HTTPS URLs pointing to native text-layer PDF documents. Duplicate and whitespace-padded URLs are normalized automatically.

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

Choose whether to return clean Markdown, plain text, or both in each dataset row.

## `shouldIncludePages` (type: `boolean`):

When enabled, includes a structured pages array with per-page text, Markdown, and character counts alongside the full document fields.

## `startPage` (type: `integer`):

1-based inclusive first page to extract from each PDF. Leave blank to start at page 1.

## `endPage` (type: `integer`):

1-based inclusive last page to extract from each PDF. Leave blank to extract through the final page.

## `maxFileSizeMegabytes` (type: `integer`):

Maximum allowed PDF download size in megabytes (1 to 50 MB). Oversized files are skipped cleanly with zero charge.

## `requestTimeoutSeconds` (type: `integer`):

Maximum seconds to wait for each PDF to download before skipping it cleanly with zero charge.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "outputFormat": "both",
  "shouldIncludePages": false,
  "maxFileSizeMegabytes": 50,
  "requestTimeoutSeconds": 30
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

## `runSummary` (type: `string`):

No description

# 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"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("alias_md5/pdf-markdown-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"] }

# Run the Actor and wait for it to finish
run = client.actor("alias_md5/pdf-markdown-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"
  ]
}' |
apify call alias_md5/pdf-markdown-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alias_md5/pdf-markdown-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/6bqDJ3zZAHZXuDGj5/builds/dEIAhvkG3eyLdSG4Z/openapi.json
