# PDF to Text API — Extract PDF Text to Clean JSON for LLM & RAG (`omao/pdf-text`) Actor

Extract clean, structured text from any PDF by URL, page by page. Returns one row per page with de-hyphenated, whitespace-normalized text. Fast, no setup.

- **URL**: https://apify.com/omao/pdf-text.md
- **Developed by:** [Marouane Oulabass](https://apify.com/omao) (community)
- **Categories:** Developer tools
- **Stats:** 1 total users, 1 monthly users, 91.7% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.44 / 1,000 pdf 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.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF to Text API — Extract PDF Text to Clean JSON for LLM & RAG

**Convert any PDF to clean, structured text by URL — one JSON row per page.** Give this Actor one or many PDF links and get back de-hyphenated, whitespace-normalized text that's ready for LLMs, RAG pipelines, search indexes or your database. No OCR setup, no local tooling, no PDF libraries to install.

> AI-agent ready: this Actor is callable and payable by AI agents via [x402](https://docs.apify.com/platform/integrations/x402) (USDC on Base), no Apify account required.

### How to extract text from a PDF by URL (no libraries)

Skip pdfminer, PyPDF and their edge cases: send a URL, get JSON. The Actor downloads each PDF, extracts the embedded text layer page by page, rejoins hyphenated line-breaks, normalizes whitespace and returns one clean row per page. Works on reports, invoices, research papers, contracts, manuals and ebooks.

### How to prepare PDFs for LLMs, embeddings and RAG

Each page arrives as a separate, already-clean chunk — a natural unit for embedding:

- **RAG pipelines** — feed the per-page `text` straight into your chunking/embedding step; `page` and `pdfUrl` give you citations for free.
- **LLM context** — pull exactly the pages you need instead of pasting whole documents.
- **Search & indexing** — make a PDF library full-text searchable with page-level hits.
- **Document processing** — extract text from invoices, statements and forms at scale.

### What you get — one clean row per page

| Field | Description |
|---|---|
| `text` | **Clean page text** — de-hyphenated, whitespace-normalized |
| `page` | Page number (1-based) |
| `pageCount` | Total pages in the document |
| `charCount` | Characters extracted on the page |
| `pdfUrl` | Source PDF URL |
| `ok`, `scrapedAt` | Status & provenance |

### Example — PDF URL in, JSON out

**Input**

```json
{ "pdfUrls": ["https://example.com/annual-report.pdf"], "maxPagesPerPdf": 50 }
```

**Output (one item = one page)**

```json
{
  "pdfUrl": "https://example.com/annual-report.pdf",
  "page": 1,
  "pageCount": 48,
  "text": "Annual Report 2025. In this financial year the company delivered...",
  "charCount": 2184,
  "ok": true
}
```

Export the dataset as **JSON, CSV, Excel or HTML**, or pull it via the API into Google Sheets, a vector store or your app.

### Why this PDF text extractor

- ✅ **Clean, usable text** — hyphenated line-breaks rejoined, whitespace normalized; no post-processing needed.
- 📑 **Page-level granularity** — one row per page keeps document structure and enables citations.
- 🌐 **Any PDF by URL** — public reports, papers, statements, manuals; batch as many as you like.
- ⚡ **Pay per page extracted** — failed or empty pages are never billed.
- 🤖 **LLM-ready by design** — each page is already a natural chunk for embeddings and RAG.

### Input options

- `pdfUrls` *(required)* — one or more PDF URLs (`https://` added if missing).
- `maxPagesPerPdf` — cap pages per PDF. Leave empty for all pages.

### FAQ

**How do I convert a PDF to text online via API?**
POST the Actor run with your `pdfUrls` (or use the Apify console), then read the dataset — one JSON row per page.

**Does it work on scanned/image PDFs?**
It extracts embedded text layers (digital PDFs). Purely scanned image-only PDFs without a text layer won't yield text.

**Can I process many PDFs in one run?**
Yes — pass a list of URLs; every row carries its `pdfUrl` and `page`, so results stay attributable.

**How is the text cleaned?**
Hyphenated words split across line breaks are rejoined and whitespace is normalized for readable, model-friendly output.

**Can I export to CSV, Excel or Google Sheets?**
Yes — one-click dataset export, or live via the API.

**What does it cost?**
Pay-per-page — you're only charged for pages actually extracted.

***

*Tip: feed the per-page `text` straight into your embedding pipeline — each page is already a natural chunk.*

# Actor input Schema

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

URLs of PDF files to extract text from (https:// added if missing).

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

Cap the number of pages extracted per PDF. Leave empty for all pages.

## `healthCheckMode` (type: `boolean`):

Internal monitoring: extract a canary PDF and FAIL if broken (no billing).

## Actor input object example

```json
{
  "pdfUrls": [
    "https://example.com/report.pdf"
  ],
  "healthCheckMode": false
}
```

# Actor output Schema

## `pages` (type: `string`):

All extracted PDF pages (page number, text, char count).

# 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/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("omao/pdf-text").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/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("omao/pdf-text").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print("💾 Check your data here: https://console.apify.com/storage/datasets/" + run["defaultDatasetId"])
for item in client.dataset(run["defaultDatasetId"]).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/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call omao/pdf-text --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "command": "npx",
            "args": [
                "mcp-remote",
                "https://mcp.apify.com/?tools=omao/pdf-text",
                "--header",
                "Authorization: Bearer <YOUR_API_TOKEN>"
            ]
        }
    }
}

```

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/acts/HqDk45iTHWquINgfs/builds/VtmCgUG2fVw1Mfmyy/openapi.json
