# PDF to Markdown & Text Extractor (`hiras2014/pdf-to-markdown`) Actor

Convert PDF files to clean Markdown or plain text for LLMs, RAG and search. Rebuilds headings, paragraphs and lists, removes running headers and footers, and handles Japanese, Chinese and Korean. One row per document or per page. Pay only for pages that contain text.

- **URL**: https://apify.com/hiras2014/pdf-to-markdown.md
- **Developed by:** [竣祐 平木](https://apify.com/hiras2014) (community)
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 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.

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 Markdown & Text Extractor

Turn PDF files into clean **Markdown** or **plain text** that language models, RAG pipelines and search indexes can use directly. Give the Actor links to PDF files and get the content back with headings, paragraphs and lists rebuilt from the layout.

- Detects titles and numbered section headings (`## 3 Method`, `### 3.1 Data`).
- Joins broken lines into paragraphs and re-joins words hyphenated across lines.
- Removes running headers, footers and page numbers.
- Handles Japanese, Chinese and Korean text, joined without stray spaces.
- One row per document or one row per page, with document metadata.
- You pay only for pages that contain text. Failed files cost nothing.

### What you can do with it

- **RAG and search:** convert reports, papers and manuals into text you can chunk and embed. Use page mode to cite page numbers.
- **Summarizing and analysis:** feed whole documents to an LLM without layout noise.
- **Archiving and migration:** move PDF content into a knowledge base or CMS.
- **AI agents:** call the Actor as a tool to read a PDF found on the web.

### Input

| Field | What it does |
| --- | --- |
| **PDF URLs** | Direct links to PDF files, one per line. |
| **Output format** | `markdown` (default) or `text`. |
| **Rows** | `document` (default): one row per file. `page`: one row per page. |
| **Page range** | For example `1-5` or `1,3,10-12`. Empty means all pages. |
| **Maximum pages per document** | Stop after this many pages. 0 means no limit. |
| **Remove running headers and footers** | On by default. |
| **Insert page markers** | Adds `<!-- page N -->` before each page in document mode. |
| **PDF password** | For password-protected files. |

```json
{
    "pdfUrls": ["https://arxiv.org/pdf/1706.03762v7"],
    "outputFormat": "markdown",
    "outputMode": "document"
}
```

### Output

One dataset item per document:

```json
{
    "url": "https://arxiv.org/pdf/1706.03762v7",
    "fileName": "1706.03762v7",
    "fileSizeBytes": 2215244,
    "pageCount": 15,
    "pagesExtracted": 15,
    "pagesWithText": 15,
    "markdown": "# Attention Is All You Need\n\n...\n\n## 1 Introduction\n\nRecurrent neural networks, long short-term memory ...",
    "characterCount": 39888,
    "metadata": { "title": null, "author": null, "creator": "LaTeX with hyperref", "createdAt": "2024-04-10T21:11:43" },
    "needsOcr": false,
    "extractedAt": "2026-11-13T15:00:00.000Z"
}
```

In page mode each item also has a `page` number and holds the content of that page only. With plain-text output the content field is called `text` instead of `markdown`.

Documents longer than about two million characters are stored in full in the run's key-value store. The dataset row then contains the beginning of the text, `truncated: true`, and a link in `fullContentUrl`.

When a file cannot be processed, the row has an `error` object instead, for example `{"code": "NOT_A_PDF"}`, `HTTP_404`, `TIMEOUT`, `TOO_LARGE` (over 100 MB) or `PASSWORD_REQUIRED`.

### Pricing

You pay per page that yielded text (`page-extracted` event). Pages without text and files that fail are not charged. There is no monthly fee. Set a maximum cost per run to cap spending: the Actor stops when the limit is reached.

### Limits

- **Scanned PDFs are not supported.** The Actor reads the text layer of the PDF and does no OCR. A document without a text layer is returned with `needsOcr: true` and is not charged.
- **Tables are returned as text, not as Markdown tables.** Cell values come out in reading order.
- **Multi-column pages** follow the order in which the PDF stores the text, which is usually but not always the reading order.
- **Some PDFs contain broken character maps.** Their text comes out garbled in every tool, including copy and paste from a PDF viewer. Only OCR can recover such files.
- Images, charts and formulas are not converted.

### FAQ

**Can I convert a local file?** Upload it to an Apify key-value store (or any place that gives you a direct link) and pass the URL.

**How fast is it?** Text extraction takes well under a second for a typical 15-page paper. Most of the run time is the download.

**Does it send my documents to an AI service?** No. Conversion happens inside the Actor run with the open-source pdf.js library. Nothing is sent to third parties.

# Actor input Schema

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

Links to PDF files, one per line. Each link must point directly to the file. To convert a file from your computer, upload it to a key-value store first and paste its URL here.

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

Markdown keeps headings and lists as Markdown syntax. Plain text returns the same content without markup.

## `outputMode` (type: `string`):

One row per document is convenient for reading and summarizing. One row per page is convenient for search indexes and citations with page numbers.

## `pageRange` (type: `string`):

Pages to convert, for example "1-5" or "1,3,10-12". Leave empty for all pages. Applies to every document in the list.

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

Stop after this many pages of each document. 0 means no limit.

## `removeHeadersFooters` (type: `boolean`):

Drop lines that repeat in the top or bottom margin of most pages, such as page numbers and journal titles.

## `pageMarkers` (type: `boolean`):

In document mode with Markdown output, add an HTML comment such as  before each page so you can trace text back to its page.

## `password` (type: `string`):

Only needed for password-protected files. The same password is tried for every document.

## `downloadTimeoutSecs` (type: `integer`):

Give up on a file that does not finish downloading within this time.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762v7"
  ],
  "outputFormat": "markdown",
  "outputMode": "document",
  "maxPagesPerDocument": 0,
  "removeHeadersFooters": true,
  "pageMarkers": false,
  "downloadTimeoutSecs": 120
}
```

# Actor output Schema

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

Dataset items: url, fileName, pageCount, pagesWithText, markdown or text, characterCount, metadata, needsOcr, and an error object for files that could not be processed.

## `files` (type: `string`):

Key-value store records (document-0001.md and so on) that hold the full content of documents too long for a dataset row.

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

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

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

```

## MCP server setup

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