# PDF to Text & Markdown Extractor for RAG & AI | $3/1K PDFs (`mauve_bunch/pdf-text-markdown-extractor`) Actor

Extract clean text and Markdown from PDF URLs for RAG, AI agents and data pipelines. Per-page text, metadata (title, author, dates), word counts and scanned-PDF detection. No proxy, no API key. $3 per 1,000 PDFs; failed and image-only PDFs are free.

- **URL**: https://apify.com/mauve_bunch/pdf-text-markdown-extractor.md
- **Developed by:** [Impakt](https://apify.com/mauve_bunch) (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

from $2.40 / 1,000 pdf 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?

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 Text & Markdown Extractor: Clean Text from PDF URLs for RAG, AI Agents & Pipelines

> **Try it in one click:** press Start with the two prefilled PDFs (a US tax form and the "Attention Is All You Need" paper) and get clean text and Markdown in about 5 seconds. **$3 per 1,000 PDFs.** PDFs that fail to download or have no text layer are free.

**Turn PDF links into clean, structured text.** Give the Actor a list of PDF URLs and it downloads each file, reads the embedded text layer and returns **plain text**, **Markdown** (headings and bullet lists detected from font sizes), optional **per-page text**, **metadata** (title, author, creator, creation and modification dates, PDF version), page and word counts, and a SHA-256 hash of the file.

It is built for **RAG pipelines, AI agents and LLM workflows** that need reliable document text, and for research, compliance, finance and data teams that process reports, filings, papers, invoices, manuals and contracts at scale. Everything is plain HTTP plus a PDF parser: no browser, no proxy, no API key.

### What you get

| Field | Description |
|---|---|
| `url`, `status`, `error` | Source link and outcome (`ok`, `no_text_layer`, `not_a_pdf`, `download_failed`, `too_large`, `password_protected`, `invalid_pdf`, `invalid_url`) |
| `text` | Extracted plain text, paragraphs separated by blank lines |
| `markdown` | Markdown with `#`/`##`/`###` headings and `-` bullets |
| `pages` | Optional array of `{page, text}` for citations and chunking |
| `title`, `author`, `subject`, `creator`, `producer` | PDF metadata when present |
| `createdAt`, `modifiedAt`, `pdfVersion` | Dates in ISO format |
| `pageCount`, `pagesExtracted`, `truncated` | Size of the document and how much was processed |
| `wordCount`, `charCount` | Quick size metrics for chunking and cost estimates |
| `needsOcr` | `true` when the PDF has almost no embedded text (a scan) |
| `fileSizeBytes`, `sha256`, `processingMs` | Useful for caching and de-duplication |

#### Input example

```json
{
  "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
  "outputFormat": "both",
  "includePages": true,
  "maxPagesPerPdf": 50
}
```

#### Output example (shortened)

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "ok",
  "title": null,
  "pageCount": 15,
  "pagesExtracted": 15,
  "wordCount": 5879,
  "needsOcr": false,
  "markdown": "# Attention Is All You Need\n\nAbstract\n\nThe dominant sequence transduction models are based on complex recurrent or convolutional neural networks ...",
  "sha256": "..."
}
```

### Pricing

Pay per event, no subscription:

| Event | Price |
|---|---|
| Actor start | $0.0001 |
| Each PDF extracted | $0.003 (about **$3 per 1,000 PDFs**, discounts on paid Apify plans) |

You are **not charged** for failed downloads, invalid files, password-protected files, oversized files, or PDFs without a text layer. Use *Max PDFs* and Apify's maximum charge per run to cap spending.

### Use cases

- **RAG and AI agents:** convert documents to Markdown before chunking and embedding. Call the Actor through the Apify API or MCP server.
- **Finance and compliance:** extract text from filings, reports and policies for search or review.
- **Research:** build corpora from open-access papers and public reports.
- **Document pipelines:** pair with the Apify scheduler and webhooks to process new PDFs automatically, and keep the `sha256` to skip duplicates.

### How it works

1. Each URL is validated (only public http/https addresses are allowed) and downloaded with size limits and retries.
2. The file is parsed with Mozilla's pdf.js, and text items are grouped into lines.
3. Line font sizes are compared with the document's body font to detect headings. Bullets and hyphenated line breaks are handled, and rotated margin text (such as arXiv stamps) is ignored.
4. Results are returned as one dataset item per PDF.

### Honest limits

- **No OCR.** Scanned PDFs (images of text) are detected and returned as `no_text_layer` free of charge. Use an OCR tool for those.
- **Markdown is heuristic.** Headings and lists come from font sizes, so unusual layouts can differ. Tables are returned as text, not Markdown tables. Multi-column pages are read in vertical order and may interleave columns.
- **Password-protected PDFs** are not opened.
- Only the first *Max pages per PDF* pages are processed (100 by default). Larger files than *Max file size* are skipped.
- Some servers block automated downloads; those links are reported as `download_failed`.

### Legality

The Actor only downloads the files you list. You are responsible for having the right to process those documents and for following copyright, privacy and data-protection laws that apply to them. The Actor does not crawl websites and does not collect personal data on its own.

### FAQ

**Does it read PDFs from Google Drive, Dropbox or S3?** Use a direct public download link (for Drive, a `uc?export=download` link). Private links that need login cannot be fetched.

**Can I send the PDF content instead of a URL?** Not yet; upload the file somewhere with a direct link or an Apify key-value store public URL.

**How fast is it?** Typically a few documents per second for normal reports; large files depend on size and the number of pages.

**Which output should I use for LLMs?** `markdown` keeps headings, which helps chunking; `pages` helps with citations.

### Feedback

Found this useful? A quick review on the Store helps others find it. Issues or feature requests? Open an issue and I'll reply fast.

# Actor input Schema

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

Direct links to PDF files (http or https). Private or local addresses are blocked.

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

Plain text, Markdown (headings and lists are detected from font sizes), or both.

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

Adds a `pages` array with the text of each page (useful for citations and chunking).

## `maxPagesPerPdf` (type: `integer`):

Only the first N pages are extracted (the result is marked `truncated`).

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

Larger files are skipped (free).

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

PDFs processed in parallel. Raise memory if you raise this.

## `maxPdfs` (type: `integer`):

Safety cap per run.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.irs.gov/pub/irs-pdf/f1040.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ],
  "outputFormat": "both",
  "includePages": false,
  "maxPagesPerPdf": 100,
  "maxFileSizeMb": 50,
  "concurrency": 3,
  "maxPdfs": 1000
}
```

# Actor output Schema

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

Dataset items: extracted text, Markdown and metadata per PDF.

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

SUMMARY record with counts for this run.

# 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://www.irs.gov/pub/irs-pdf/f1040.pdf",
        "https://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("mauve_bunch/pdf-text-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://www.irs.gov/pub/irs-pdf/f1040.pdf",
        "https://arxiv.org/pdf/1706.03762",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("mauve_bunch/pdf-text-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://www.irs.gov/pub/irs-pdf/f1040.pdf",
    "https://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call mauve_bunch/pdf-text-markdown-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,mauve_bunch/pdf-text-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/3sbo8y6loTlAurFaZ/builds/X8cBATdz6nemLvGEF/openapi.json
