# PDF Tables Extractor — Tables Out of Any PDF (`alaudinburki/pdf-tables-extractor`) Actor

Pull real tables out of PDFs as rows you can use, with a confidence score on every table. Outputs one item per row for spreadsheets, or Markdown and CSV for docs and LLM prompts. Says plainly when a PDF is a scan with no text layer instead of returning silent nonsense.

- **URL**: https://apify.com/alaudinburki/pdf-tables-extractor.md
- **Developed by:** [alaudin burki](https://apify.com/alaudinburki) (community)
- **Categories:** Developer tools, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.00 / 1,000 results

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 Tables Extractor — Tables Out of Any PDF

Getting a table out of a PDF is one of the genuinely hard, genuinely common manual jobs. A single Stack
Overflow question about it has been read **131,000+ times**, and "merge/convert PDFs" over **1.3 million**.

The reason it's hard: **a PDF has no concept of a table.** It stores characters at coordinates. The rows
and columns you see are an illusion your eye assembles, and software has to reconstruct them.

### What you get

One dataset item **per table row**, ready to drop into a spreadsheet — or one item per table with rows
nested, if you prefer. Plus Markdown (for docs, issues and LLM prompts) and optional CSV.

| Field | Description |
|---|---|
| `row` | The row as an object keyed by the table's header |
| **`confidence`** | 0–1: how sure we are this is a real table, not a diagram |
| `header` · `hasHeader` | Detected header row; duplicate and blank names are made unique |
| `page` · `tableIndex` · `rowIndex` | Exactly where it came from |
| `markdown` · `csv` | The whole table, ready to paste |
| `fillRatio` · `columnConsistency` · `numericRatio` · `symbolRatio` · `singleCharRatio` | The signals behind the score, so you can filter on your own terms |

### Why `confidence` exists — and why you should use it

**Table detection is genuinely ambiguous.** A boxed diagram is geometrically identical to a table. Any
tool claiming perfect extraction is either lying or hasn't tested on messy documents.

So every table is scored on five signals, and low scorers are dropped rather than presented as fact:

- **fill ratio** — sparse grids are usually layout artefacts
- **column consistency** — a real column is populated on most rows
- **average cell length** — one-character cells mean a diagram
- **numeric ratio** — real tables carry data
- **symbol / single-character ratio** — catches keyboard layouts and glyph charts

**Measured honestly on a deliberately hostile test:** on a PDF containing a keyboard diagram, the naive
approach reported **4 tables**. With scoring, that drops to **2** — while a genuine table in another PDF
is kept at **0.81** confidence and extracted with correct headers and cells.

**It is not zero.** Two false positives survive on that document. For financial or statistical work,
**raise `minConfidence` to 0.7+ and check `header` before trusting a row.** A wrong table is worse than
no table, and this actor is built to let you make that call rather than make it for you.

### Input

```json
{
  "pdfUrls": [{ "url": "https://example.com/annual-report.pdf" }],
  "pages": "12-30",
  "minConfidence": "0.45",
  "outputMode": "rows"
}
```

### Sample output

```json
[
  {
    "sourceUrl": "https://css4.pub/2015/textbook/somatosensory.pdf",
    "page": 3,
    "tableIndex": 1,
    "confidence": 0.81,
    "hasHeader": true,
    "header": "column_1, Rapidly adapting, Slowly adapting",
    "rowIndex": 1,
    "row": {
      "column_1": "Surface receptor / small receptive field",
      "Rapidly adapting": "Hair receptor, Meissner's corpuscle: detect an insect or a very fine vibration.",
      "Slowly adapting": "Merkel's receptor: used for spatial details, e.g. a round surface edge."
    },
    "status": "ok"
  }
]
```

### Run summary

Every completed run also writes a `SUMMARY` record in the default key-value store. It reports PDFs
opened, pages processed, tables detected/kept/rejected, returned items, scan detection, and the safe
next action. Use it to distinguish “no usable table” from a successful extraction before consuming
dataset rows downstream.

### Typical uses

- **Financial reports → spreadsheet** — pull the tables out of a 10-K or an annual report.
- **Scientific and government data** — statistical releases publish tables as PDFs and nothing else.
- **Invoices and statements** — line items into a ledger.
- **Feeding an LLM** — the Markdown output is the format models handle best.
- **Migrating legacy documents** — years of PDF-only reports into a database.

### Pricing

**$4.00 / 1,000 rows** (`$0.004` per result), plus a near-zero start fee. Priced above the simple
scrapers because the work is real — PDF parsing is CPU-bound, not a fetch. Never charged beyond
`maxItems`.

### ⚠️ Read before you rely on it

- **Scanned PDFs will not work.** If a page is an image of a document, there is no text to extract. This
  is detected and reported as `little_or_no_text_layer` in the `QUALITY_REPORT` — you get an explicit
  answer, not silent nonsense. **OCR is not performed.**
- **Borderless tables are harder** than ruled ones and score lower. Lowering `minConfidence` finds more
  of them and also more false positives. That trade-off is yours to make.
- **Merged cells and multi-row headers** flatten. Complex layouts may need a manual pass.
- **Check `confidence` before trusting financial figures.** Genuinely — that is what it is for.

### FAQ

- **Does it do OCR?** No. Scanned documents are detected and reported, not guessed at.
- **Why is this actor Python when the rest are Node?** Because `pdfplumber` has no real JavaScript
  equivalent. It was tried in Node first with `pdfjs-dist`: that produced both false positives (a
  keyboard diagram read as a table) *and* false negatives (a real table missed entirely). Language
  chosen per job, not by preference.
- **Can it handle password-protected PDFs?** No.
- **What if my PDF has no tables?** You get an explicit `no_tables_found` row explaining what to try.

### Related actors

- **PDF Text Extractor** — whole-document or per-page text when you don't need tables.
- **Docs to Answers Pack** — turn documentation into citable, AI-ready chunks.

# Actor input Schema

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

Public URLs of the PDFs to extract tables from.

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

Which pages to read, e.g. 1-5,8. Leave empty for every page.

## `minConfidence` (type: `string`):

Tables below this 0-1 score are discarded. Detection is genuinely ambiguous — a boxed diagram looks like a table to any algorithm — so this is the dial between missing tables and inventing them. 0.45 is a balanced default; raise it for financial data.

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

'rows' gives one dataset item per table row, ready for a spreadsheet. 'tables' gives one item per table with the rows nested.

## `includeMarkdown` (type: `boolean`):

Attach each table as Markdown — the format to paste into docs, issues or an LLM prompt.

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

Attach each table as a CSV string.

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

Upper bound on pages read from each document.

## `maxItems` (type: `integer`):

Hard cap on items returned. You are never charged beyond this.

## Actor input object example

```json
{
  "pdfUrls": [
    {
      "url": "https://css4.pub/2015/textbook/somatosensory.pdf"
    }
  ],
  "minConfidence": "0.45",
  "outputMode": "rows",
  "includeMarkdown": true,
  "includeCsv": false,
  "maxPagesPerPdf": 100,
  "maxItems": 5000
}
```

# Actor output Schema

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

Extracted table rows with confidence scores.

## `qualityReport` (type: `string`):

Tables found vs kept, scanned-PDF detection and problems.

# 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": [
        {
            "url": "https://css4.pub/2015/textbook/somatosensory.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("alaudinburki/pdf-tables-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": [{ "url": "https://css4.pub/2015/textbook/somatosensory.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("alaudinburki/pdf-tables-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": [
    {
      "url": "https://css4.pub/2015/textbook/somatosensory.pdf"
    }
  ]
}' |
apify call alaudinburki/pdf-tables-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,alaudinburki/pdf-tables-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/k1k8ug7ba02Rucz8R/builds/NvlYSZR83YHfJkxVy/openapi.json
