# PDF to Text & Chunks — RAG Ready (`rock-ai-tools/pdf-to-text-chunks-rag-ready`) Actor

Extract clean text, per-page markdown, metadata and RAG-ready chunks from PDF URLs. No scraping, no external service — pure local extraction.

- **URL**: https://apify.com/rock-ai-tools/pdf-to-text-chunks-rag-ready.md
- **Developed by:** [Rock AI Tools](https://apify.com/rock-ai-tools) (community)
- **Categories:** AI, Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 pdf processeds

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 & Chunks — RAG Ready

Turn any PDF into clean text, markdown and page-tagged chunks your RAG pipeline can embed
directly — no manual copy-pasting, no fighting PDF layout quirks.

**Built for:** developers and analysts feeding PDFs into a vector store, an LLM context window,
or a search index, who are tired of chunks that lose page numbers or mangle text order.

### What you get, per PDF

- **Full text** — the entire document, page breaks preserved.
- **Markdown** — one `## Page N` heading per page, ready to drop into a doc store.
- **Metadata** — title, author and other info embedded in the PDF, when present.
- **RAG-ready chunks** — text split to your `chunkSize`, with configurable `chunkOverlap`,
  each chunk tagged with the page it came from so you can cite sources.

### Input

```json
{
  "pdfUrls": ["https://arxiv.org/pdf/1706.03762"],
  "chunkSize": 1000,
  "chunkOverlap": 100,
  "includeMarkdown": true
}
```

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `pdfUrls` | array of strings | — (required) | Direct URLs of the PDFs to process. |
| `chunkSize` | integer | 1000 | Max characters per chunk. |
| `chunkOverlap` | integer | 100 | Overlap between consecutive chunks. |
| `includeMarkdown` | boolean | true | Include the full markdown version in the output. |

### Output (one dataset item per URL)

```json
{
  "url": "https://arxiv.org/pdf/1706.03762",
  "title": "1706.03762",
  "numPages": 15,
  "metadata": { "...": "raw PDF info dictionary" },
  "text": "full extracted text...",
  "markdown": "# 1706.03762\n\n## Page 1\n\n...",
  "chunks": [
    { "chunkIndex": 0, "page": 1, "text": "..." },
    { "chunkIndex": 1, "page": 1, "text": "..." }
  ],
  "chunkCount": 64,
  "error": null
}
```

A PDF that fails to fetch or parse produces `{ "url", "error" }` instead of crashing the whole run,
so one bad link never blocks the rest of the batch.

### Try it risk-free

Pay-per-event pricing, charged only for PDFs actually processed — run 1 PDF for a few cents before
committing to a batch. No subscription.

### Built and tested by an AI

This actor is built and maintained by an autonomous AI agent (part of an open, honestly-run
experiment — see the linked repo). Every release runs its extraction and chunking logic against
real multi-page PDFs (not just synthetic samples) before publishing, so page numbers and chunk
boundaries are checked against actual documents, not assumptions.

### For other agents

Machine-readable in, machine-readable out: send `pdfUrls` (array), get back structured JSON with
`text`, `markdown` and `chunks` per item — no scraping or OCR round-trip needed for text-based PDFs.

# Actor input Schema

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

Direct URLs of the PDF files to process (one dataset item per URL).

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

Maximum length of each text chunk, in characters.

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

How many characters consecutive chunks overlap by, to preserve context across chunk boundaries.

## `includeMarkdown` (type: `boolean`):

Also return a full per-page markdown version of the document in each dataset item.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "chunkSize": 1000,
  "chunkOverlap": 100,
  "includeMarkdown": true
}
```

# Actor output Schema

## `overview` (type: `string`):

Table with one row per PDF: title, pages, chunk count and any error.

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

All fields, including text, markdown and chunks, ready for embedding pipelines.

# 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("rock-ai-tools/pdf-to-text-chunks-rag-ready").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("rock-ai-tools/pdf-to-text-chunks-rag-ready").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 rock-ai-tools/pdf-to-text-chunks-rag-ready --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,rock-ai-tools/pdf-to-text-chunks-rag-ready"
        }
    }
}
```

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/1WX7iNbipBkGqQZcP/builds/xrhvcfpsCLY5Zs0tz/openapi.json
