# PDF to Text & Markdown — Extract Text, Pages, RAG Chunks (`boliveira/pdf-text-extract`) Actor

Extract text from PDF URLs as plain text, Markdown with headings, per-page rows or RAG-ready chunks, plus metadata. Fast, no start fee, scanned PDFs without a text layer are flagged and not charged.

- **URL**: https://apify.com/boliveira/pdf-text-extract.md
- **Developed by:** [Bruno Scherer Oliveira](https://apify.com/boliveira) (community)
- **Categories:** AI, Developer tools
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

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

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 — Extract Text, Pages, RAG Chunks

Turn PDF links into clean text in seconds. You get **plain text**, **Markdown with headings**, **one row per page**, or **overlapping chunks ready for embeddings and RAG**, plus document metadata (title, author, dates, page count).

There's **no start fee and one simple price per PDF**. **Scanned PDFs without a text layer are flagged and not charged**, and neither are failed downloads.

### Use cases

- Feed reports, papers, contracts and manuals into LLMs, vector databases and RAG pipelines
- Bulk-convert PDF libraries to searchable text or Markdown
- Pull text from specific pages, e.g. the first 3 pages of every annual report
- Index PDFs linked from your own sites or datasets

### Input

| Field | What it does |
|---|---|
| **PDF URLs** | Direct links to PDF files |
| **Output layout** | `document` (one row per PDF), `pages` (one row per page) or `chunks` (RAG chunks) |
| **Markdown** | Adds Markdown with headings detected from font sizes |
| **Page range** | e.g. `1-5,8,10-` |
| **Max pages per PDF** | Cap long documents |
| **Chunk size / overlap** | For the `chunks` layout. Chunks break at paragraph, line or sentence boundaries |
| **Max file size** | Larger files are skipped and not charged (default 50 MB) |
| **Parallel downloads** | 1–10 at once. Requests to the same host are spaced 1 second apart |

Example: RAG chunks from a paper.

```json
{ "urls": ["https://arxiv.org/pdf/1706.03762"], "output": "chunks", "chunkSize": 1500, "chunkOverlap": 200 }
```

### Output

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "status": "ok",
  "fileSizeBytes": 2215244,
  "pageCount": 15,
  "pagesExtracted": 15,
  "wordCount": 6214,
  "metadata": { "title": null, "author": null, "creator": "LaTeX with hyperref", "producer": "pdfTeX-1.40.25", "createdAt": "2024-04-10T21:11:43", "pdfVersion": "1.5", "encrypted": false },
  "text": "Provided proper attribution is provided, Google hereby grants permission …",
  "markdown": "# Attention Is All You Need\n\n…\n\n### Abstract\n\nThe dominant sequence transduction models …",
  "charged": true
}
```

In the `pages` layout each row adds `page`, and in the `chunks` layout each row adds `chunkIndex` and `chunkCount`.

**Statuses:**

- `ok`: text extracted, charged once per PDF
- `no_text_layer`: a scanned or image-only PDF, not charged (it needs OCR, which this Actor doesn't do)
- `failed`: download error, not a PDF, or too large, with the reason in `error`, not charged

### Good to know

- Extraction uses Mozilla's [pdf.js](https://mozilla.github.io/pdf.js/), the engine inside Firefox. Text comes out in reading order per line. Complex multi-column layouts and tables come out as text lines, not as a layout.
- Markdown headings are inferred from font size, so they're a helpful structure rather than a perfect outline.
- Only process PDFs you're allowed to access and use.

### Pricing

**One charge per successfully extracted PDF**, whatever the layout or page count. No start fee.

# Actor input Schema

## `urls` (type: `array`):

Direct links to PDF files (http or https).

## `output` (type: `string`):

document = one row per PDF with the full text; pages = one row per page; chunks = overlapping text chunks for RAG / embeddings. You pay per PDF in every layout.

## `markdown` (type: `boolean`):

Also return Markdown with headings detected from font sizes (chunks are built from it when on).

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

Pages to extract, e.g. 1-5,8,10-. Empty = all pages.

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

0 = no limit.

## `chunkSize` (type: `integer`):

For the chunks layout. Chunks break at paragraph, line or sentence boundaries where possible.

## `chunkOverlap` (type: `integer`):

Characters repeated between consecutive chunks (at most half the chunk size).

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

Add a pages array to each document row.

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

Larger files are skipped (not charged).

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

PDFs processed at once (1-10). Requests to the same host are spaced 1 second apart.

## Actor input object example

```json
{
  "urls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "output": "document",
  "markdown": true,
  "maxPages": 0,
  "chunkSize": 2000,
  "chunkOverlap": 200,
  "includePages": false,
  "maxFileSizeMb": 50,
  "concurrency": 4
}
```

# Actor output Schema

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

Rows per PDF, page or chunk, with status for failed and image-only PDFs.

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

RUN_SUMMARY: extracted, image-only, failed and charged counts.

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

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

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

```

## MCP server setup

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

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/xgX1uUPBXsGCXiE8r/builds/JEtxzpUVPeZFzyub9/openapi.json
