# PDF Text Extractor: PDF to Markdown & Text for LLMs (`forgeloop/pdf-to-markdown`) Actor

Extract text from PDF files as clean Markdown and plain text. Bulk PDF URLs in, one item per file out, with headings, paragraphs and lists kept. Built for LLM, RAG, AI agents and search indexes. No browser, fast and cheap. Pay per page, failed files are free.

- **URL**: https://apify.com/forgeloop/pdf-to-markdown.md
- **Developed by:** [Markus Heiß](https://apify.com/forgeloop) (community)
- **Categories:** AI, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.50 / 1,000 pages

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

## PDF Text Extractor: PDF to Markdown & Text for LLMs

Turn PDF files into clean Markdown and plain text. Give it a list of PDF links, get back one item per file with the full document as Markdown.

Made for people who feed documents into LLMs, RAG pipelines, search indexes or note apps and are tired of broken line breaks and lost headings.

### What it does

- Downloads each PDF from its URL.
- Rebuilds the reading structure from the text layer:
  - **Headings** from font size (`#`, `##`, `###`)
  - **Paragraphs** joined across line breaks, hyphenated words repaired
  - **Bullet and numbered lists**
- Adds optional page markers (`<!-- page 3 -->`) so you can cite pages.
- Returns the title and author from the PDF metadata.
- Runs without a browser, so it is fast and cheap.

### Input

| Field | Description | Default |
|---|---|---|
| PDF URLs | Direct links to PDF files | |
| Max pages per file | Pages beyond this limit are skipped and not charged | 500 |
| Page markers | Insert `<!-- page N -->` before each page | on |
| Include plain text | Also return raw text with line breaks | on |
| Max file size (MB) | Larger files are skipped with an error | 50 |

### Output

One dataset item per PDF:

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "fileName": "1706.03762",
  "title": "Attention Is All You Need",
  "author": null,
  "pageCount": 15,
  "convertedPages": 15,
  "truncated": false,
  "markdown": "<!-- page 1 -->\n\n# Attention Is All You Need\n\n...",
  "text": "Attention Is All You Need\n...",
  "characters": 39876,
  "error": null
}
```

Export as JSON, CSV or Excel, or read it through the Apify API.

### Pricing

Pay per converted page. Pages without text (for example scanned images) and failed files are not charged. You can cap the cost of a run with the maximum charge setting in Apify.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start.

### Limits

- Scanned PDFs without a text layer return an error that says so. They need OCR.
- Tables are returned as text lines, not as Markdown tables.
- Multi-column layouts are read in the order the PDF stores the text, which is usually correct but not always.
- Only public `http` and `https` links. Password protected PDFs are not supported.

### Data source, permitted use and legal

- **Data source:** The files at the URLs you enter. The Actor downloads each file once during the run.
- **Snapshot:** Results show the source at the time of the run. We do not guarantee that they are complete, current or correct.
- **For business use:** This Actor is offered to businesses only, not to consumers.
- **Permitted use:** Process only content you are allowed to access and use, for example your own websites and documents or public pages you have a legitimate reason to process. Respect the terms of the websites and the rights in the content.
- **Your responsibility:** You choose the URLs and decide what happens with the results. If results contain personal data, you are the controller and need your own legal basis.
- **No circumvention:** The Actor does not log in, solve captchas or bypass paywalls, bot protection or other access restrictions. Do not use it for that.
- **Request volume:** One download per PDF link. Do not use it to put excessive load on a website.
- **Provider:** forgeloop, Markus Heiss, Austria. [Imprint](https://devhem.github.io/forgeloop-legal/imprint.html), [Privacy Notice](https://devhem.github.io/forgeloop-legal/privacy.html), [Terms of Use](https://devhem.github.io/forgeloop-legal/terms.html).

### Questions and issues

Open an issue on the Actor page. Bugs are fixed quickly.

# Actor input Schema

## `sources` (type: `array`):

Direct links to PDF files. One output item per file. Format: a list of objects with a url key, like \[{"url": "https://example.com/report.pdf"}]. Plain strings are not accepted.

## `maxPagesPerFile` (type: `integer`):

Stop after this many pages of each file. Pages beyond the limit are not converted and not charged.

## `includePageMarkers` (type: `boolean`):

Insert an HTML comment like  before each page in the Markdown output.

## `includePlainText` (type: `boolean`):

Also return the raw text with line breaks, next to the Markdown.

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

Files larger than this are skipped with an error.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ],
  "maxPagesPerFile": 500,
  "includePageMarkers": true,
  "includePlainText": true,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

## `results` (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 = {
    "sources": [
        {
            "url": "https://arxiv.org/pdf/1706.03762"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forgeloop/pdf-to-markdown").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 = { "sources": [{ "url": "https://arxiv.org/pdf/1706.03762" }] }

# Run the Actor and wait for it to finish
run = client.actor("forgeloop/pdf-to-markdown").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 '{
  "sources": [
    {
      "url": "https://arxiv.org/pdf/1706.03762"
    }
  ]
}' |
apify call forgeloop/pdf-to-markdown --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,forgeloop/pdf-to-markdown"
        }
    }
}
```

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/DVc70UbbTO6xzcLzV/builds/ovDqr75R0VxZ7E36g/openapi.json
