# PDF Table Extractor & Invoice OCR to Excel (`dealmahal/pdf-table-extractor`) Actor

Turn tables in PDFs, scanned documents and photos into clean rows for Excel, CSV and JSON. Reads digital PDFs exactly and scans with built-in OCR, plus invoice number, dates, tax and total. No API key. $1 per 1,000 digital pages, $8 per 1,000 scanned.

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

## Pricing

from $0.80 / 1,000 pages read

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/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 & Invoice OCR to Excel

**Turn the tables inside PDFs, scanned documents and photos into clean rows** you can open in Excel, Google Sheets or any database. Digital PDFs are read exactly from their own text layer. Scanned pages and images are read with built-in OCR. Add one switch and every invoice also gets its number, date, currency, tax and total. No API key, no account anywhere else, no code needed.

**In one line:** paste PDF or image links, press Start, download your tables as Excel, CSV or JSON. You pay per page read: $1 per 1,000 digital pages, $8 per 1,000 scanned pages.

**Try it free:** Apify's free plan includes $5 of monthly usage. That covers about 5,000 digital pages or 625 scanned pages. Use **Dry run** first to see the exact page count and cost before any page is charged.

### Key facts

| | |
|---|---|
| **Input** | Links to PDFs or images (PNG, JPG, TIFF, WEBP, BMP), up to 200 files and 50 MB each |
| **Output** | One record per table row (cells plus named columns), or one record per table, or page text |
| **Invoices** | Invoice number, invoice date, due date, currency, subtotal, tax and total, in English, German, French and Spanish layouts |
| **Scans** | Open-source OCR runs inside the tool; pages without a text layer are detected automatically |
| **Price** | $0.001 per digital page, $0.008 per scanned page or image; failed files are not charged |
| **Free preview** | Dry run counts pages and pages that need OCR, with no page charges |
| **Privacy** | Your files are processed in memory for your run only; results stay in your own Apify storage |

### Who uses it

- **Finance and bookkeeping teams** turning supplier invoices into rows for reconciliation.
- **Analysts and researchers** pulling statistics tables out of reports and government PDFs.
- **Developers and AI agents** that need clean JSON from documents inside an automated workflow.
- **Operations teams** processing scanned receipts, delivery notes and price lists in bulk.

### Ready-made examples (real runs)

| Example | What you get | Cost of that run |
|---|---|---|
| Two public sample PDFs (default input) | A French telecom invoice and a US statistics report: 3 pages, 4 tables, **74 rows**, in about 8 seconds | $0.003 |
| Three sample invoices with invoice fields | AWS (USD 4.11), a German hosting invoice (EUR 34.73) and an Indian hotel receipt (INR 1,939): 4 pages, 57 table rows plus 3 invoice records | $0.004 |
| A photographed receipt (OCR) | A Swiss restaurant receipt: receipt number 4572, CHF, tax 3.85, total 54.50, in about 7 seconds | $0.008 |

Every number above comes from real runs of this tool on public sample files.

### How to use it

1. Click **Try for free** and open the input form.
2. Paste direct links to your PDFs or images under **PDF or image links**, one per line.
3. Keep **Output** on *One row per table row* for Excel or CSV.
4. Switch on **Add invoice fields** if your files are invoices or receipts.
5. Optional: set **Pages** (for example `1-3`) or turn on **Dry run** to preview the cost.
6. Press **Start**, then export the dataset as Excel, CSV or JSON, or open the **Invoice fields** view.

**Where to host your files:** any public direct-download link works, for example a Dropbox link ending in `?dl=1`, a public S3 or Google Cloud Storage link, or a file uploaded to an Apify key-value store with public read access. Links to a web page that only *shows* the file (not the file itself) are refused with a clear message and are not charged.

### Input

Minimal input:

```json
{ "files": ["https://example.com/invoice.pdf"] }
```

Fuller example:

```json
{
  "files": ["https://example.com/invoice-1.pdf", "https://example.com/scan.jpg"],
  "outputType": "rows",
  "invoiceFields": true,
  "ocr": "auto",
  "pages": "1-3",
  "maxPagesPerFile": 50
}
```

| Field | Type | Default | What it does |
|---|---|---|---|
| `files` | list of links | required | Direct links to PDFs or images. Up to 200 per run, 50 MB each. |
| `outputType` | `rows`, `tables` or `text` | `rows` | `rows`: one record per table row. `tables`: one record per table. `text`: page text only. |
| `invoiceFields` | true/false | false | Adds one `invoice` record per file with number, dates, currency, subtotal, tax and total. Free. |
| `ocr` | `auto`, `always` or `never` | `auto` | `auto` uses OCR only for pages without a text layer and for images. |
| `headerRow` | `auto`, `yes` or `no` | `auto` | Whether the first row of each table holds the column names. |
| `pages` | text | all | Page range per file, for example `1-3,5` or `2-`. |
| `maxPagesPerFile` | number | 50 | Safety limit on pages read and charged per file (maximum 500). |
| `dryRun` | true/false | false | Counts pages and OCR pages only. Nothing is charged. |

### Output

A table row (from the default example):

```json
{
  "type": "row",
  "file": "free_fiber.pdf",
  "page": 1,
  "table": 1,
  "row": 4,
  "method": "text-layer",
  "cells": ["Total facture", "24.99", "5.00", "29.99"],
  "data": { "column_1": "Total facture", "Montant EUR HT": "24.99", "Montant TVA": "5.00", "Montant EUR TTC": "29.99" }
}
```

An invoice record (from the invoice example):

```json
{
  "type": "invoice",
  "file": "QualityHosting.pdf",
  "invoiceNumber": "30064443",
  "invoiceDate": "7. Mai 2014",
  "currency": "EUR",
  "subtotal": null,
  "tax": null,
  "total": 34.73
}
```

| Field | Meaning |
|---|---|
| `type` | `row`, `table`, `page`, `invoice`, `preview` or `error` |
| `file`, `fileUrl` | File name and the link you gave |
| `page`, `table`, `row` | Where the row sits (all 1-based) |
| `method` | `text-layer` (exact, from the PDF) or `ocr` (read from the image) |
| `cells` | Cell values left to right; `null` means an empty cell |
| `data` | The same row with column names, when a header row is found |
| `invoiceNumber`, `invoiceDate`, `dueDate`, `currency`, `subtotal`, `tax`, `total` | Invoice fields; each stays `null` unless a labelled value is found |
| `pagesInFile`, `pagesNeedingOcr` | Dry-run counts |
| `error` | Why a file could not be read (never charged) |

The run summary (pages, OCR pages, tables, rows, failed files) is saved as `RUN_SUMMARY` in the run's key-value store.

### Pricing

You pay only for pages actually read. Pages are never charged for downloads that fail, files that are not PDFs or images, password-protected files or dry runs.

| Apify plan | Digital page | Scanned page or image |
|---|---|---|
| Free and Starter | $0.001 | $0.008 |
| Scale | $0.0008 | $0.0064 |
| Business and above | $0.0008 | $0.0048 |

Example: a 3-page digital invoice costs $0.003; 1,000 scanned receipts cost $8 on Starter. Each run also has Apify's standard start fee of $0.00005 per GB of memory, which is $0.0001 at the default 2 GB.

### Use it from AI agents (MCP)

Add this tool to Claude, ChatGPT, Cursor or any MCP client with:

```
https://mcp.apify.com?tools=dealmahal/pdf-table-extractor
```

Example prompts:

- "Extract the line items from these 5 invoice PDFs and give me a CSV."
- "Read this scanned receipt and tell me the total and the tax."
- "Pull the table from page 3 of this report into JSON."

### Use it from code

Python:

```python
from apify_client import ApifyClient
client = ApifyClient("<YOUR_APIFY_TOKEN>")
run = client.actor("dealmahal/pdf-table-extractor").call(run_input={
    "files": ["https://example.com/invoice.pdf"], "invoiceFields": True})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

JavaScript:

```javascript
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: '<YOUR_APIFY_TOKEN>' });
const run = await client.actor('dealmahal/pdf-table-extractor').call({ files: ['https://example.com/invoice.pdf'] });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
```

cURL (waits for the result):

```bash
curl -X POST "https://api.apify.com/v2/acts/dealmahal~pdf-table-extractor/run-sync-get-dataset-items?token=<YOUR_APIFY_TOKEN>" \
  -H "Content-Type: application/json" -d '{"files":["https://example.com/invoice.pdf"]}'
```

### FAQ

**Does it work with scanned PDFs and phone photos?** Yes. Pages without a text layer and all images are read with OCR automatically. Clear, straight scans at 200 DPI or more give the best results.

**How accurate is it?** Digital PDFs are read exactly from the file's own text. OCR is very good on printed text; handwriting is not supported. Tables with clear columns come out best; very irregular layouts may need a quick check.

**Are invoice fields guessed?** No. A field is filled only when the document has a matching label such as "Invoice No.", "Total" or "MwSt", and stays `null` otherwise.

**Which languages?** Digital PDFs work in any language. OCR is strongest on English and Chinese and reads most Western European text; a few accented letters (such as ö, ß, ç, ñ) and the €, £ and ₹ signs may be missed on scans, so for scanned invoices the currency is taken from codes such as EUR or CHF when they are printed. Invoice labels are understood in English, German, French and Spanish.

**What happens to my files?** They are downloaded into the run's memory, processed, and discarded when the run ends. Results stay in your own Apify account. Only process documents you have the right to use.

**Can I limit what I spend?** Yes. Set *Maximum pages per file*, use a page range, run a free dry run first, and set a maximum charge per run in Apify. The tool stops cleanly at your limit.

### Other DealMahal tools

| Tool | What it does |
|---|---|
| [Greenhouse, Lever & Ashby Jobs API](https://apify.com/dealmahal/greenhouse-lever-ashby-jobs) | Live jobs from company career sites, with a monitor for new and closed roles |
| [Companies Hiring Now](https://apify.com/dealmahal/companies-hiring-now) | Which companies are hiring for a role, with open-role counts |
| [Salary Benchmarks from Job Postings](https://apify.com/dealmahal/salary-benchmarks-from-job-postings) | Pay ranges from jobs that publish salaries |
| [Workable Jobs API](https://apify.com/dealmahal/workable-jobs-api) | Jobs from companies hiring on Workable |
| [Personio Jobs API](https://apify.com/dealmahal/personio-jobs-api) | Jobs from European companies hiring on Personio |

### How it works and responsible use

Digital PDFs are parsed with the open-source pdfplumber and PDFium libraries. Scans and images are read by RapidOCR with PP-OCR models (Apache-2.0), running inside the tool, so your documents are never sent to a third-party AI service. Links are fetched only from the public internet; private network addresses are refused. You remain responsible for the documents you process, including any personal data they contain.

# Actor input Schema

## `files` (type: `array`):

Direct links to PDF files or images (PNG, JPG, TIFF, WEBP, BMP), one per line. Use public download links (for example a Dropbox link ending in ?dl=1, a public S3 or Apify key-value store link). Up to 200 files and 50 MB per file.

## `outputType` (type: `string`):

rows: every table row becomes one record with cells and, when a header row is found, named columns. tables: one record per table. text: the page text only.

## `invoiceFields` (type: `boolean`):

If true, each file also gets one 'invoice' record with invoice number, invoice date, due date, currency, subtotal, tax and total. Fields stay null unless a labelled value is found. No extra charge.

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

auto reads digital pages from their text layer and uses OCR only for scanned pages and images. always forces OCR. never skips scanned pages.

## `headerRow` (type: `string`):

auto detects header rows. yes treats the first row of every table as column names. no keeps every row as data.

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

Optional page range per file, for example 1-3,5 or 2-. Empty means all pages (up to the page limit below).

## `maxPagesPerFile` (type: `integer`):

Safety limit on pages read (and charged) per file. Default 50, maximum 500.

## `dryRun` (type: `boolean`):

If true, only counts pages and how many need OCR, so you can see the exact cost first. Nothing is charged.

## Actor input object example

```json
{
  "files": [
    "https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/free_fiber.pdf"
  ],
  "outputType": "rows",
  "invoiceFields": false,
  "ocr": "auto",
  "headerRow": "auto",
  "maxPagesPerFile": 50,
  "dryRun": false
}
```

# Actor output Schema

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

Table rows, tables, page text, invoice fields and file errors.

## `summary` (type: `string`):

Pages read, pages with OCR, tables, rows and files that failed.

# 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 = {
    "files": [
        "https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/free_fiber.pdf",
        "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/tests/pdfs/nics-background-checks-2015-11.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("dealmahal/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 = { "files": [
        "https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/free_fiber.pdf",
        "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/tests/pdfs/nics-background-checks-2015-11.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("dealmahal/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 '{
  "files": [
    "https://raw.githubusercontent.com/invoice-x/invoice2data/master/tests/compare/free_fiber.pdf",
    "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/tests/pdfs/nics-background-checks-2015-11.pdf"
  ]
}' |
apify call dealmahal/pdf-table-extractor --silent --output-dataset

```

## MCP server setup

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