# PDF Table Extractor: PDF Tables to Excel, CSV & JSON (OCR) (`fguiraud/pdf-table-extractor`) Actor

Extract every table from PDFs (native or scanned), Word, PowerPoint and web pages into Excel (.xlsx, one sheet per table), CSV and JSON. Handles multi-page tables, academic-paper tables and optional borderless detection. OCR for scans. No API key; pay per document.

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

## Pricing

from $3.00 / 1,000 documents

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

### What does PDF Table Extractor do?

**PDF Table Extractor** finds **every table** in your PDFs and documents and gives it back as an **Excel workbook (.xlsx, one sheet per table)**, **CSV files** and **structured JSON** (header + rows). It works with **native and scanned PDFs** (OCR), **Word (DOCX), PowerPoint (PPTX), Excel, HTML pages and images**.

Paste document URLs or Google Drive / Dropbox / OneDrive links and download the tables. No API key, no templates to draw, and you **pay only per document processed**, however many tables it has.

It runs on the Apify platform, so you also get an API, scheduling, integrations (Google Sheets, Make, Zapier, n8n) and access for **AI agents through the [Apify MCP server](https://mcp.apify.com)**.

![Sample output: real rows from a run of this Actor](https://fernandoguiraud16-coder.github.io/data-tools/assets/outputs/output-pdf-table-extractor.png?v=3)

### Why use it?

- 📊 **PDF to Excel without copy-paste**: financial statements, annual reports, price lists, invoices, government statistics.
- 🔗 **Multi-page tables** with the header repeated on each page are **merged into one table**.
- 🎓 **Academic papers**: tables drawn with horizontal rules only (LaTeX booktabs), which most tools return as jumbled text.
- 🖨️ **Scanned documents**: pages without a text layer are read with OCR in 7 languages.
- 🌐 **Whole report pages**: point it at a web page and enable **Also process documents linked from web pages** to extract the tables of every PDF linked there.
- 🔢 **Numbers stay numbers** in Excel (`1,234.5` becomes 1234.5), while codes with leading zeros stay text.

### How to extract tables from a PDF

1. Click **Try for free**.
2. Paste one or more PDF (or DOCX/PPTX/XLSX/HTML) URLs.
3. Click **Start**.
4. Open the **files.xlsx** link in the results to download the Excel workbook, or export the **Tables** view as CSV/Excel.

### Input

| Field | Description | Default |
|---|---|---|
| `sources` | Document URLs (PDF, DOCX, PPTX, XLSX, HTML, images; share links work) | required |
| `saveFiles` | Save an Excel workbook and one CSV per table, with download links | `true` |
| `tableDetection` | `lines` (ruled tables, precise) or `text` (also borderless tables, experimental) | `lines` |
| `ocr` | `auto` (only pages without text), `always` or `never` | `auto` |
| `pageRange` | e.g. `1-5, 8` | all pages |
| `followDocumentLinks` | Extract tables from documents linked on a web page | `false` |

```json
{
  "sources": [{ "url": "https://example.com/annual-report.pdf" }],
  "tableDetection": "lines"
}
```

### Output

One row per document. The **Tables** view shows one row per table. You can download the dataset in various formats such as JSON, HTML, CSV, or Excel.

```json
{
  "source": "https://example.com/annual-report.pdf",
  "status": "ok",
  "fileType": "pdf",
  "tableCount": 2,
  "pagesProcessed": 12,
  "tables": [
    {
      "index": 0,
      "page": 4,
      "header": ["Year", "Revenue", "Net income"],
      "rows": [["2024", "1,234.5", "210.3"], ["2025", "1,410.2", "251.9"]],
      "csv": "Year,Revenue,Net income\n2024,\"1,234.5\",210.3\n2025,\"1,410.2\",251.9\n"
    }
  ],
  "files": {
    "xlsx": "https://api.apify.com/v2/key-value-stores/.../records/001-annual-report-tables.xlsx",
    "tables": ["https://api.apify.com/v2/key-value-stores/.../records/001-annual-report-table-1.csv"]
  }
}
```

### Data fields

| Field | Description |
|---|---|
| `tableCount` | Number of tables found |
| `tables[].page` / `tables[].index` | Where the table is |
| `tables[].header` / `tables[].rows` | Table cells as text |
| `tables[].csv` | The table as CSV |
| `files.xlsx` | Excel workbook with every table of the document |
| `files.tables` | One CSV file per table |
| `pagesProcessed`, `ocrPages` | Pages processed and pages read with OCR |

### How much does PDF table extraction cost?

| Event | Price |
|---|---|
| Run start (per GB of memory) | $0.001 |
| Document processed (any number of pages and tables) | **$0.003** |
| OCR page (only scanned pages without text) | $0.01 |

100 native PDFs cost about **$0.30**. Failed documents are free. Set **Max cost per run** and the Actor stops cleanly at that limit.

### Use it with AI agents (MCP)

Add `https://mcp.apify.com?tools=fguiraud/pdf-table-extractor` to Claude, Cursor or any MCP client and ask: *"Get the income statement table from this annual report as CSV."*

**Agent-friendly input**: common field names such as `url`, `urls`, `startUrls`, `query` or `keywords` are accepted, and an empty input runs a small sample from the input form (with a note in the results) instead of failing.

### Need the full text too?

For the whole document as **LLM-ready Markdown**, RAG chunks and AI field extraction (invoices, contracts), use [PDF to Markdown Extractor & Document Parser](https://apify.com/fguiraud/document-to-markdown-tables), built on the same engine.

Only need the plain text and metadata? [PDF Text Extractor](https://apify.com/fguiraud/pdf-text-extractor) returns the full text, the text of each page, page count, title and author.

### FAQ and limitations

- **My table was not found.** Try `tableDetection: "text"` for tables without borders or rules.
- **Charts**: values drawn in a PDF chart image are not extracted, but PowerPoint chart data is returned as a table.
- **Encrypted PDFs**: enter the password in **PDF password**.
- Found a problem or need a feature? Open an issue on the **Issues** tab. Replies within 48 hours.

# Changelog

This Actor's version history is a separate document: https://apify.com/fguiraud/pdf-table-extractor/changelog.md

# Actor input Schema

## `sources` (type: `array`):

PDF (native or scanned), Word, PowerPoint, Excel, HTML pages or images with tables. Share links from Google Drive, Dropbox, OneDrive and GitHub work too (shared as 'Anyone with the link').

## `saveFiles` (type: `boolean`):

Save all tables of each document as an Excel workbook (.xlsx, one sheet per table) and each table as a .csv file; the result includes their download links.

## `tableDetection` (type: `string`):

'lines': detect tables drawn with borders/grid lines (precise, recommended). 'text': also detect borderless tables by aligning text columns (experimental: finds more tables, but columns can be split imperfectly).

## `followDocumentLinks` (type: `boolean`):

If a source URL is a web page, find links to PDF/DOCX/XLSX/XLS/PPTX/CSV files on it and convert those documents instead (e.g. a reports, filings or publications page). The page itself is not billed.

## `maxLinkedDocuments` (type: `integer`):

Limit for 'Also process documents linked from web pages'.

## `ocr` (type: `string`):

'auto': run OCR only on scanned pages that contain no text (recommended). 'always': OCR every page, even if it has a text layer. 'never': no OCR (images and scanned pages return no text). OCR pages are billed separately.

## `ocrLanguages` (type: `array`):

Languages of the scanned text. Adding more languages is slightly slower.

## `pageRange` (type: `string`):

Pages to process, e.g. '1-5, 8'. Applies to PDF pages, PowerPoint slides and Excel sheets. Leave empty for all.

## `maxPages` (type: `integer`):

Safety limit on pages processed per document.

## `pdfPassword` (type: `string`):

Password for encrypted PDFs (applies to all PDFs in the run).

## `maxFileSizeMb` (type: `integer`):

Documents larger than this are skipped (not billed).

## `base64Files` (type: `array`):

For files that are not reachable by URL, e.g. from an AI agent or a local script: a list of objects {"fileName": "report.pdf", "content": "<base64>"}. A data: URI is also accepted as content. Keep the total input under ~9 MB; use URLs for bigger files.

## `failOnError` (type: `boolean`):

Mark the run as FAILED when a document cannot be processed or yields no text. Useful for pipelines and monitoring. Successfully processed documents are still returned (and billed).

## `maxConcurrency` (type: `integer`):

How many documents are processed at the same time.

## Actor input object example

```json
{
  "sources": [
    {
      "url": "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/background-checks.pdf"
    }
  ],
  "saveFiles": true,
  "tableDetection": "lines",
  "followDocumentLinks": false,
  "maxLinkedDocuments": 20,
  "ocr": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "maxPages": 500,
  "maxFileSizeMb": 50,
  "failOnError": false,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

No description

## `files` (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 = {
    "sources": [
        {
            "url": "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/background-checks.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("fguiraud/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 = { "sources": [{ "url": "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/background-checks.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("fguiraud/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 '{
  "sources": [
    {
      "url": "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/background-checks.pdf"
    }
  ]
}' |
apify call fguiraud/pdf-table-extractor --silent --output-dataset

```

## MCP server setup

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