# 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, AI
- **Features:** Limited permissions
- **Stats:** 5 total users, 2 monthly users, 96.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/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 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(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/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call omao/pdf-text --silent --output-dataset

```

## MCP server setup

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

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/HqDk45iTHWquINgfs/builds/nSfSmdcC1GnLceqnA/openapi.json
