# PDF Table Extractor (Text + OCR) (`freecamp008/pdf-table-extractor`) Actor

Extract tables from any PDF into clean rows, JSON records and CSV. Works on digital PDFs via text positions and on scanned PDFs via built-in OCR. No external APIs.

- **URL**: https://apify.com/freecamp008/pdf-table-extractor.md
- **Developed by:** [Camp8 fr0](https://apify.com/freecamp008) (community)
- **Categories:** Developer tools, Automation, AI
- **Features:** Limited permissions, Single-tenant, Server interface
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $8.00 / 1,000 table extracteds

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.

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 Table Extractor – Convert PDF Tables to JSON, CSV & Excel-ready Rows (with OCR)

**PDF Table Extractor** finds every table in a PDF and turns it into clean, structured data: raw rows, JSON records keyed by the column headers, and a ready-to-save CSV. It works on **digital PDFs** (bank statements, financial reports, price lists, government statistics) and on **scanned PDFs** thanks to built-in OCR. Everything runs inside the Actor. No external APIs, no per-page fees to third parties, and your documents never leave Apify.

### What does PDF Table Extractor do?

- 📄 **Detects tables automatically** on every page, including several tables per page.
- 🧭 **Reconstructs columns from text positions** (whitespace-river clustering), so it works on tables **without ruling lines**, which is where most PDF-to-Excel tools break.
- 🏷️ **Detects headers**, including **multi-line headers** (e.g. "Decreased" / "Accel" becomes `Decreased Accel`), and returns JSON records keyed by column name.
- 🔁 **Merges wrapped cells** (multi-line descriptions) back into a single row.
- 🔍 **OCR fallback for scanned PDFs**: pages without a text layer are rendered at 300 DPI, table ruling lines are removed, and the text is read with Tesseract (100+ languages).
- 🔢 **Keeps numbers intact**: `1,234.56`, `1.234,56`, `1 234,56`, percentages, negatives in parentheses.
- 🌐 **HTTP API (Standby mode)**: call it like a REST endpoint with GET or POST and get JSON back in one request.

### Use cases

- Extract **financial statements, bank statements and annual report tables** into spreadsheets
- Convert **price lists and product catalogs** from suppliers into a database
- Pull **government and statistical tables** (census, health, budgets) for analysis
- Digitize **scanned archives** with tables
- Feed **RAG / LLM pipelines** with properly structured tables instead of garbled text
- Automate **accounts-payable** and **procurement** document flows

### How to use it

1. Click **Try for free**.
2. Paste one or more **PDF URLs**.
3. (Optional) Choose pages (`1-3,7`), OCR mode and OCR language.
4. Click **Start**. Each table appears as a row in the **Tables** view. Export to JSON, CSV, Excel or HTML, or use the API.

#### Call it as an HTTP API (Standby mode)

```bash
## GET with query parameters
curl "https://<your-standby-url>/?pdfUrls=https://example.com/report.pdf&pages=1-5" \
  -H "Authorization: Bearer <APIFY_TOKEN>"

## POST with a JSON body (same fields as the Actor input)
curl -X POST "https://<your-standby-url>/" \
  -H "Authorization: Bearer <APIFY_TOKEN>" -H "Content-Type: application/json" \
  -d '{"pdfUrls":["https://example.com/report.pdf"],"ocrMode":"auto"}'
```

Response: `{ "count": 3, "items": [ ...tables... ] }`

You can also run it through the Apify API (`run-sync-get-dataset-items`), the Apify MCP server, Make, Zapier, n8n and other integrations. **AI agents can pay per call with x402 (USDC)** through Apify's agentic payments, without needing an Apify account.

### Input example

```json
{
  "pdfUrls": ["https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"],
  "pages": "1-10",
  "ocrMode": "auto",
  "ocrLanguage": "eng",
  "minRows": 3,
  "minColumns": 2,
  "includeCsv": true
}
```

| Field | Description |
|---|---|
| `pdfUrls` | Direct links to PDF files |
| `pages` | Page selection like `1-3,5,10-` (empty = all) |
| `ocrMode` | `auto` (OCR only scanned pages), `always`, `never` |
| `ocrLanguage` | Tesseract code(s): `eng`, `fra`, `deu`, `spa`, `eng+fra`… |
| `minRows` / `minColumns` | Filter out small false-positive "tables" |
| `maxPagesPerPdf` | Safety limit per document |
| `includeCsv` | Add a CSV string per table |
| `password` | For encrypted PDFs |

### Output example

```json
{
  "pdfUrl": "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf",
  "page": 1,
  "tableIndex": 1,
  "method": "text",
  "rowCount": 8,
  "columnCount": 7,
  "header": ["Cycle Name", "KI (1/km)", "Distance (mi)", "Improved Speed", "Decreased Accel", "Eliminate Stops", "Decreased Idle"],
  "headerRowCount": 3,
  "records": [
    { "Cycle Name": "2012_2", "KI (1/km)": "3.30", "Distance (mi)": "1.3", "Improved Speed": "5.9%", "Decreased Accel": "9.5%", "Eliminate Stops": "29.2%", "Decreased Idle": "17.4%" }
  ],
  "rows": [["Cycle", "KI", "Distance", "", "", "", ""], ["2012_2", "3.30", "1.3", "5.9%", "9.5%", "29.2%", "17.4%"]],
  "csv": "Cycle,KI,Distance,,,,\n...",
  "bbox": { "x0": 125.3, "x1": 489.1, "top": 388.2, "bottom": 512.7 }
}
```

### Pricing

This Actor uses **pay-per-event** pricing. You only pay for results:

| Event | Price |
|---|---|
| Table extracted | **$8 per 1,000 tables** ($0.008 each) |
| OCR page (scanned pages only) | **$12 per 1,000 pages** ($0.012 each) |

Digital PDFs never trigger OCR charges in `auto` mode. Apify platform usage (compute) is billed separately and is typically a fraction of a cent per document. Set **Maximum cost per run** to cap your spend; the Actor stops cleanly when the limit is reached.

### FAQ

**Does it work with scanned PDFs?**
Yes. In `auto` mode, pages with no text layer are OCR'd automatically. Use `always` for PDFs with a broken or garbage text layer.

**Which languages does OCR support?**
All Tesseract languages, including English, French, German, Spanish, Italian, Portuguese, Dutch, Arabic, Chinese and Japanese. Combine them with `+`, e.g. `eng+fra`.

**What about tables without borders/lines?**
That's the main strength of this Actor: columns are reconstructed from text positions, not from drawn lines.

**How accurate is it?**
Digital PDFs with clear column alignment give near-perfect results. Very dense tables whose columns almost touch can occasionally merge two columns. OCR accuracy depends on scan quality (300 DPI or better recommended).

**How big can PDFs be?**
Up to 150 MB per file. Use `maxPagesPerPdf` and `pages` to control large documents.

**Is my data private?**
Files are processed inside your Apify run. Nothing is sent to third-party services.

**Can I get Excel?**
Yes. Export the dataset as XLSX or CSV from the Console or API, or use the per-table `csv` field.

# Actor input Schema

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

Direct links to PDF files (digital or scanned). Each detected table becomes one result.

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

Page selection like <code>1-3,5,10-</code>. Leave empty for all pages.

## `ocrMode` (type: `string`):

<b>auto</b>: OCR only pages without a text layer (scanned). <b>always</b>: OCR every page. <b>never</b>: text layer only (fastest).

## `ocrLanguage` (type: `string`):

Tesseract language code(s), e.g. <code>eng</code>, <code>fra</code>, <code>deu</code>, <code>spa</code>, or combined like <code>eng+fra</code>.

## `minRows` (type: `integer`):

Ignore detected tables with fewer rows (including header).

## `minColumns` (type: `integer`):

Ignore detected tables with fewer columns.

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

Safety limit on pages processed per PDF.

## `includeCsv` (type: `boolean`):

Add a ready-to-save CSV version of each table.

## `password` (type: `string`):

Password for encrypted PDFs (optional).

## Actor input object example

```json
{
  "pdfUrls": [
    "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"
  ],
  "pages": "1-3",
  "ocrMode": "auto",
  "ocrLanguage": "eng",
  "minRows": 3,
  "minColumns": 2,
  "maxPagesPerPdf": 100,
  "includeCsv": true
}
```

# Actor output Schema

## `tables` (type: `string`):

No description

# 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://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("freecamp008/pdf-table-extractor").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://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("freecamp008/pdf-table-extractor").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://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf"
  ]
}' |
apify call freecamp008/pdf-table-extractor --silent --output-dataset

```

## MCP server setup

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

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/rsVPmRCfNdZpb5QxX/builds/jaZzPxDMGaMWpXGr3/openapi.json
