# PDF to Text, Tables & RAG Chunks API (`appropriate_songbird/pdf-text-tables-chunker`) Actor

Turn PDF URLs into clean per-page text, table rows and overlapping RAG chunks with page references. Handles up to 50 PDFs per run, skips empty pages, flags scanned files, nothing stored after the run.

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

## Pricing

Pay per event

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, Tables & RAG Chunks API (no OCR, from $0.001 per chunk)

**Turn PDF links into clean, page-aware text, table rows and embedding-ready chunks, in one API call.**

Give the Actor up to 50 links to PDF files and it returns structured data you can drop straight into a search index, a vector database, a spreadsheet or an LLM prompt. It reads the text layer of each PDF, keeps page numbers, pulls ruled tables out as arrays of rows, and can cut the text into overlapping chunks that remember which pages they came from.

No browser, no login, no API key. Your documents are fetched, parsed and thrown away.

### What people use it for

- **RAG and AI knowledge bases**: switch to *RAG chunks* and get 300 to 8,000 character chunks with overlap and `pageStart` / `pageEnd`, ready for any embedding model, so answers can cite the page.
- **Contract, policy and report digestion**: one item per page with word counts, so you can route long documents or search them page by page.
- **Tables from reports**: financial statements, price lists and spec sheets with ruled grids come back as `tables`, each a list of rows.
- **Compliance and archive pipelines**: schedule a run over a list of document URLs and compare the text between versions.
- **Clean-up before analysis**: optional redaction of emails and phone numbers before the text goes anywhere else.

### Sample output (pages mode)

```json
{
  "sourceUrl": "https://example.com/reports/q3.pdf",
  "documentTitle": "Q3 Results",
  "totalPages": 12,
  "kind": "page",
  "pageNumber": 4,
  "text": "Revenue by region ...",
  "wordCount": 312,
  "charCount": 2011,
  "tableCount": 1,
  "tables": [[["Region", "Q1", "Q2"], ["North", "10", "12"], ["South", "8", "9"]]]
}
```

In *RAG chunks* mode each item has `kind: "chunk"`, `chunkIndex`, `pageStart`, `pageEnd` and `text` instead.

### Inputs

| Input | What it does |
|---|---|
| PDF URLs | Direct http(s) links, up to 50 per run, 50 MB each |
| Output mode | One item per page, or RAG chunks |
| Extract tables | Ruled tables as rows (pages mode) |
| Max pages per PDF | Reads the first N pages (1 to 500, default 100) |
| Chunk size / overlap | Characters per chunk (300 to 8,000) and repeated overlap |
| Redact emails and phone numbers | Replaces them with `[email removed]` / `[phone removed]` |
| Include empty pages | Off by default: pages without text are skipped and not charged |
| Max items per run | Hard cap on pages or chunks delivered (default 500) |

Bad input (no URLs, a non-http link, overlap larger than chunk size) stops the run straight away with a plain message and no per-item charges.

### How much does it cost?

Pay per event: **$0.005 per run**, plus **$0.002 per page** with text (pages mode) or **$0.001 per chunk** (chunks mode). Nothing else: no monthly fee, no per-PDF fee.

| Job | Output | Cost |
|---|---|---|
| One 5-page PDF, pages mode | 5 pages | $0.015 |
| One 40-page report, pages mode | 40 pages | about $0.085 |
| One 40-page report, RAG chunks (1,200 characters) | roughly 55 chunks | about $0.06 |
| 50 contracts of 20 pages each, pages mode | 1,000 pages | about $2.01 |
| Scanned PDF with no text layer | nothing | $0 |

You are never charged for pages without text, for documents that fail to download or parse, or past the *Maximum cost per run* you set. Apify's free plan includes monthly credit, so you can try it before paying anything.

### Quick start

1. Click **Try for free** and keep the prefilled PDF link (a small table PDF from the W3C), or paste your own direct PDF links.
2. Choose *One item per page* for text and tables, or *RAG chunks* for embeddings.
3. Press **Start**. Results appear in the Output tab in seconds, and you can download JSON, CSV, Excel or HTML, or call the Actor from the Apify API, Make, n8n or Zapier.

### FAQ

**Does it do OCR for scanned PDFs?** No. It reads the text layer, which is what almost all exported reports, contracts, papers and statements have. Scanned files are flagged in `RUN_SUMMARY` and not charged, so you can send them to an OCR tool instead.

**Can I use it for RAG or a vector database?** Yes. Chunks mode returns overlapping chunks with `pageStart` and `pageEnd`, so your answers can cite the page. Chunk size is 300 to 8,000 characters.

**How are tables returned?** As arrays of rows per page, for tables drawn with cell borders. Borderless tables come back as text lines.

**Is it good for bulk jobs?** Up to 50 PDFs per run, 50 MB each, up to 500 pages per PDF. One bad link never stops the others, and `RUN_SUMMARY` lists every URL with its status.

**Are my files stored?** No. Each file is parsed from a temporary copy and deleted straight after.

**Can I take the text of the same website too?** Pair it with the [Website SEO Audit & Broken Link Checker](https://apify.com/appropriate_songbird/site-seo-audit-link-checker) to find PDF links and broken ones across a site.

### Good to know

- **Text-layer PDFs only.** Scanned or image-only PDFs have no text to read. They are reported as "no text layer" in `RUN_SUMMARY` and not charged. OCR is not included.
- **Tables** are detected where the PDF draws cell borders. Borderless layouts usually come back as plain text lines, and merged cells can leave blank cells in a row.
- **Reading order** follows the PDF's layout. Multi-column pages can interleave columns.
- **Password-protected PDFs** are not opened.
- **Per-document report.** `RUN_SUMMARY` lists every URL with its status, pages read and any error. One bad link never stops the others.
- **Private networks are refused.** Links to localhost, internal IPs and cloud metadata addresses are blocked, redirects included.
- **Author and creator metadata are not output**, because they often contain a person's name. The document title is.

### Privacy and rights

Only submit PDFs you own or are licensed to process. The Actor fetches nothing but the URLs you list, one at a time, with a declared user agent. It keeps no copy: the file lives in a temporary file during parsing and is deleted straight after, and no input or output is stored outside your own run's dataset and key-value store. Run-health counters (runs started, succeeded, failed, last error) are kept in a named store in your account.

Built on pdfplumber and pdfminer.six (both MIT). This is an independent tool and is not affiliated with Adobe or any PDF vendor.

# Actor input Schema

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

Direct http(s) links to PDF files you own or are licensed to process (max 50 per run, 50 MB each). Links to private networks are refused.

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

pages = one dataset item per non-empty page (text + tables). chunks = overlapping text chunks sized for embeddings, each with the pages it came from.

## `extractTables` (type: `boolean`):

Detect ruled tables and return them as arrays of rows. Slower on big files.

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

Only the first N pages of each PDF are read (1 to 500). Protects your budget on very long files.

## `chunkSizeChars` (type: `integer`):

Target maximum characters per chunk (300 to 8000).

## `chunkOverlapChars` (type: `integer`):

Characters repeated from the end of the previous chunk (0 to 1000, and below the chunk size).

## `redactPersonalData` (type: `boolean`):

Replace email addresses and phone numbers in the extracted text with \[email removed] / \[phone removed].

## `includeEmptyPages` (type: `boolean`):

Pages mode only. By default pages without a text layer are skipped and not charged.

## `maxResults` (type: `integer`):

Hard cap on dataset items (pages or chunks) across all PDFs.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ],
  "outputMode": "pages",
  "extractTables": true,
  "maxPagesPerPdf": 100,
  "chunkSizeChars": 1200,
  "chunkOverlapChars": 150,
  "redactPersonalData": false,
  "includeEmptyPages": false,
  "maxResults": 500
}
```

# Actor output Schema

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

Dataset with one item per PDF page or per text chunk.

## `runSummary` (type: `string`):

Per-document status, page counts, warnings and errors 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.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("appropriate_songbird/pdf-text-tables-chunker").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.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("appropriate_songbird/pdf-text-tables-chunker").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.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ]
}' |
apify call appropriate_songbird/pdf-text-tables-chunker --silent --output-dataset

```

## MCP server setup

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

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/lfDRQaJwOOvPpoopm/builds/iz3gypEALHPqJgCyu/openapi.json
