# PDF to Text API

> PDF to text page by page with metadata; AI OCR for scanned pages and clean Markdown with tables.

Reports, contracts, papers, invoices, brochures, scanned archives: send a **PDF link** or **upload the PDF**, get back **its text page by page** with the **document metadata**. Scanned pages are read by **AI OCR** automatically, and **AI mode** returns **Markdown with headings and tables**, ready for RAG and LLM pipelines.

- Host: `pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com`
- Base URL: `https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf`
- Auth: headers `X-RapidAPI-Key` and `X-RapidAPI-Host`
- OpenAPI: https://helenis-api.com/docs/pdf/openapi.json

## Endpoints

### PDF Extraction

PDF to text and Markdown, page by page.

#### Extract PDF from URL

`POST /v1/pdf/extract`

Extract the text of a PDF from its URL. Text of every page (or of the pages you choose), the document metadata, and Markdown with headings and tables for pages read by the AI. Scanned pages are read by OCR in 'auto' mode. Credits: 1 per started 20 text-layer pages, 20 per page read by the AI.

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `url` | body | `string` | yes | Direct link to a PDF, up to 50 MB. | `https://arxiv.org/pdf/1706.03762` |
| `mode` | body | `"auto" \| "text" \| "ai"` | no | 'text': the PDF's own text layer, no AI (fast, cheapest). 'auto': text layer, and AI OCR for scanned pages only. 'ai': AI on every page, for clean Markdown with headings and tables. Default `auto`. |  |
| `pages` | body | `string` | no | Pages to extract, e.g. '1-5,8,10-12'. All pages when empty. | `1-3` |
| `password` | body | `string` | no | Password of an encrypted PDF. |  |

```bash
curl -X POST "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://arxiv.org/pdf/1706.03762",
    "mode": "ai",
    "pages": "1-3"
  }'
```

#### Extract Uploaded PDF

`POST /v1/pdf/extract/upload`

Extract the text of an uploaded PDF. Same as /extract, for a file sent as multipart/form-data (field `file`).

| Parameter | In | Type | Required | Description | Example |
|---|---|---|---|---|---|
| `file` | form | `file` | yes | PDF, up to 30 MB. |  |
| `mode` | form | `"auto" \| "text" \| "ai"` | no | 'text': the PDF's own text layer, no AI (fast, cheapest). 'auto': text layer, and AI OCR for scanned pages only. 'ai': AI on every page, for clean Markdown with headings and tables. Default `auto`. |  |
| `pages` | form | `string` | no | Pages to extract, e.g. '1-5,8,10-12'. All pages when empty. |  |
| `password` | form | `string` | no | Password of an encrypted PDF. |  |

```bash
curl -X POST "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract/upload" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com" \
  -F "file=@./my-file"
```

## Sample call

Extract PDF from URL: `POST /v1/pdf/extract`.

```bash
curl -X POST "https://pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com/v1/pdf/extract" \
  -H "X-RapidAPI-Key: YOUR_API_KEY" \
  -H "X-RapidAPI-Host: pdf-to-text-markdown-tables-scanned-pdf-ocr.p.rapidapi.com" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://arxiv.org/pdf/1706.03762",
    "mode": "ai",
    "pages": "1-3"
  }'
```

## Response

```json
{
  "source": "https://arxiv.org/pdf/1706.03762",
  "page_count": 15,
  "pages_extracted": 3,
  "text_pages": 0,
  "ai_pages": 3,
  "metadata": {
    "creator": "LaTeX with hyperref",
    "producer": "pdfTeX-1.40.25",
    "created": "2024-04-10T21:11:43+00:00"
  },
  "text": "Attention Is All You Need\nAshish Vaswani ...",
  "markdown": "Attention Is All You Need\n...\n## Abstract\n\nThe dominant sequence transduction models ...\n\n---\n\n...",
  "pages": [
    { "page": 1, "method": "ai", "text": "Attention Is All You Need ...", "markdown": "Attention Is All You Need ..." },
    { "page": 3, "method": "ai", "text": "...", "markdown": "...\n[Figure: Output Probabilities, Softmax, Linear, Add & Norm, ...]\n..." }
  ]
}
```

*A real response, shortened.* Pages taken from the text layer have `"method": "text"` and no `markdown`.

## How it works

1. **Open** the PDF (decrypted with `password` when needed) and read each page's own text layer.
2. **Choose** by mode: `text` keeps the text layer; `auto` sends pages without one (scans) to the AI; `ai` sends every page.
3. **Read** AI pages in parallel batches: scans at high resolution, digital pages at medium resolution with their native text.

## Privacy

PDFs are downloaded, read and discarded: neither the file nor its text is stored by the API. Passwords are used in memory only and never logged. The AI sub-processor may keep requests temporarily for abuse monitoring.

## Errors

```json
{ "error": { "status": 400, "code": "pdf_encrypted", "message": "The PDF is password-protected: send its password." } }
```

| Status | `code` | Meaning |
|---|---|---|
| 400 | `invalid_url`, `invalid_request`, `invalid_pages` | Fix the input. |
| 400 | `site_unreachable`, `site_blocked`, `file_too_large` | The PDF could not be downloaded (down, protected, over 50 MB). |
| 400 | `unsupported_file`, `pdf_encrypted`, `too_many_pages` | Not a PDF or damaged, password missing, or too many pages for one call. |
| 400 | `plan_limit` | Free BASIC plan: up to 20 pages, 1 of them read by the AI, per call (use `pages`). Paid plans go up to 500 and 100. Not billed. |
| 429 | `daily_limit_reached` | Daily safety limit of your plan; resets at 00:00 UTC. |
| 503 | `ai_error`, `capacity_exhausted` | Temporary failure. Retry. Not billed. |

## Pricing

1 credit per 20 text pages, 20 per page read by the AI. Failed calls are never billed.

| Plan | Price | Credits included | Above the quota |
|---|---|---|---|
| BASIC | Free | 20 / day | resets every day |
| PRO | $4.99/month | 16,000 / month | $0.0035 per credit |
| ULTRA | $14.99/month | 48,000 / month | $0.0035 per credit |
| MEGA | $49.99/month | 160,000 / month | $0.0035 per credit |

Apify actor **PDF to Text Extractor - Scanned PDF OCR**: billed per event; free-plan users get 5 PDFs of 10 pages per run.

| Event | Charged for | Price |
|---|---|---|
| `text-page` | each text-layer page | $0.0002 |
| `ai-page` | each page read by the AI | $0.0045 |

## Links

- API reference (HTML): https://helenis-api.com/docs/pdf
- OpenAPI: https://helenis-api.com/docs/pdf/openapi.json
- Overview and pricing: https://helenis-api.com/apis/pdf/
- RapidAPI listing: https://rapidapi.com/helenis-api-helenis-api-docs/api/pdf-to-text-markdown-tables-scanned-pdf-ocr?utm_source=helenis&utm_medium=site&utm_campaign=pdf&utm_content=markdown
- Apify actor: https://apify.com/helenisapi/pdf-to-text-extractor-scanned-pdf-ocr?utm_source=helenis&utm_medium=site&utm_campaign=pdf&utm_content=markdown
- MCP server (Apify): https://mcp.apify.com?tools=helenisapi/pdf-to-text-extractor-scanned-pdf-ocr

MCP: Works in Claude, Cursor, VS Code and any MCP client; billed per event through Apify (your Apify token).

## Conventions (every Helenis API)

- Auth: two headers on every call, `X-RapidAPI-Key` (your key) and `X-RapidAPI-Host` (the API's host). One RapidAPI key works for every API you subscribe to.
- Billing in credits: one for a simple call, more for heavier work (a minute of audio, a page read by AI). Each API states its rule.
- Failed calls are never billed: a `4xx` bills zero credits and a `5xx` is never counted.
- Errors share one envelope: `{"error": {"status", "code", "message"}}` with a stable machine-readable `code`.
- `400`: fix the input (validation errors are always 400, never 422); not billed.
- `429`: rate limit; wait for `Retry-After`. `503`: temporary upstream or AI failure (`ai_error`, `upstream_timeout`); retry later, not billed.
- Values the source does not give come back as `null`, never invented.
