# PDF to Excel: Invoice & Table Extractor (`egra_van/pdf-invoice-table-extractor`) Actor

PDF to Excel, CSV or JSON rows. Invoices: supplier, number, dates, VAT, totals and one row per line item, with totals cross-checked. Any other PDF: every table becomes rows. No AI, no API key. $6 per 1,000 pages with data ($4.50 on Business); empty pages and failed files free.

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

## Pricing

from $4.50 / 1,000 pdf page with data

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/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 to Excel: Invoice & Table Extractor

Turn **PDF invoices and PDF tables into rows** you can open in **Excel, Google Sheets or CSV**, or send to **n8n, Make, Zapier** and your database.

- **Invoices, bills, purchase orders:** supplier, invoice number, invoice date, due date, PO number, customer, VAT/tax ID, currency, subtotal, tax rate, tax amount, total, IBAN, and **one row per line item** (description, SKU, quantity, unit, unit price, VAT, amount).
- **Any other PDF** (price lists, statistical reports, schedules, statements): **every table becomes rows**, with the column names from the table header.
- **No AI model and no API key.** The PDF's text layer is read with open-source tools (pdfplumber), so results are repeatable and your documents are not sent to any AI service.
- **Totals are cross-checked:** each line is checked (quantity × unit price = amount) and the lines are checked against the subtotal and total, so you see at once which invoices need a human look.
- **$6 per 1,000 PDF pages with data.** Pages without any table, failed downloads and scanned pages are free.

### What you get

#### Invoices: one row per line item

Real output for the sample invoice [`invoice-us-ruled.pdf`](https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf) (a fictional invoice with a bordered item table):

```json
{
  "fileName": "invoice-us-ruled.pdf",
  "documentType": "invoice",
  "rowType": "invoice-line",
  "page": 1,
  "lineIndex": 1,
  "description": "Copy paper A4, 80 g, box of 5 reams",
  "sku": "PAP-A4-80",
  "quantity": 12,
  "unitPrice": 24.9,
  "lineTotal": 298.8,
  "lineCheck": "ok",
  "invoiceNumber": "INV-2026-0142",
  "invoiceDate": "2026-09-15",
  "dueDate": "2026-10-15",
  "poNumber": "PO-7781",
  "supplierName": "Larkspur Sample Supply Co.",
  "supplierTaxId": "00-0000142",
  "customerName": "Bluebird Sample Bakery LLC",
  "currency": "USD",
  "subtotal": 664.17,
  "taxRate": 8,
  "taxAmount": 53.13,
  "total": 717.3,
  "linesSum": 664.17,
  "totalsCheck": "ok",
  "status": "ok"
}
```

European invoices work too: decimal commas (`1.150,00`), dates like `30.09.2026`, VAT per line, borderless tables and item tables that continue on the next page. Real output for line 4 of the 2-page sample [`invoice-eu-2-pages.pdf`](https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-eu-2-pages.pdf):

```json
{
  "page": 1,
  "lineIndex": 4,
  "description": "Content updates",
  "quantity": 6.5,
  "unit": "h",
  "unitPrice": 42,
  "lineTaxRate": 21,
  "lineTotal": 273,
  "lineCheck": "ok",
  "invoiceNumber": "2026/0387",
  "invoiceDate": "2026-09-30",
  "dueDate": "2026-10-14",
  "supplierName": "Wrenfield Sample Web Studio B.V.",
  "supplierTaxId": "NL000000000B01",
  "customerName": "Harbor Lane Sample Clinic",
  "currency": "EUR",
  "subtotal": 3800.9,
  "taxRate": 21,
  "taxAmount": 798.19,
  "total": 4599.09,
  "totalsCheck": "ok",
  "iban": "NL00EXMP0000000000"
}
```

All 14 lines of that invoice (9 on page 1, 5 on page 2) come out as 14 rows, and their sum (3,800.90) matches the subtotal.

#### Any PDF: one row per table row

Real output for the USDA [Weekly Combined Regional Shell Egg Report](https://www.ams.usda.gov/mnreports/ams_2848.pdf) (a public US government price report, 2 pages, 7 borderless tables):

```json
{
  "fileName": "usda-shell-eggs-2026-10-02.pdf",
  "documentType": "tables",
  "rowType": "table-row",
  "page": 1,
  "tableIndex": 1,
  "tableTitle": "National Shell Eggs - Caged · Delivered Warehouse, White, Cents Per Dozen",
  "hasHeader": true,
  "rowIndex": 1,
  "data": {
    "Class": "Extra Large",
    "Price Range": "61.00 - 94.00",
    "Average Price": 81.88,
    "Price Change": 1,
    "Last Reported (9/25/2026)": 80.88
  }
}
```

Export the dataset to **CSV or Excel** and every key of `data` becomes its own column. The 34-page USDA [retail specialty crops report](https://www.ams.usda.gov/mnreports/fvwretail.pdf) gives **1,099 rows from 32 tables** in one run.

#### One Excel file for the whole run

With **Save one Excel file** on (default), the run also saves `OUTPUT.xlsx` in its key-value store: a sheet **Invoice lines**, a sheet **Invoices** (one row per invoice with the totals and checks) and **one sheet per table**. The link is in the run's **Output** tab and in the `OUTPUT` summary record.

### How to use it

1. Paste links to your PDFs into **PDF URLs**. Google Drive, Dropbox, OneDrive/SharePoint, Box and GitHub share links work (share them as *Anyone with the link*). You can also use files uploaded to a key-value store, or a dataset of PDF links from a crawler.
2. Keep **What to extract = Auto**, or choose **Invoices** or **Tables**.
3. Click **Start**. Download the results as Excel, CSV or JSON, open `OUTPUT.xlsx`, or read them through the API.

### Input example

```json
{
  "urls": [
    { "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf" },
    { "url": "https://www.ams.usda.gov/mnreports/ams_2848.pdf" }
  ],
  "mode": "auto",
  "tableDetection": "auto",
  "parseNumbers": true,
  "dateOrder": "auto",
  "saveExcel": true
}
```

| Field | What it does |
|---|---|
| `urls` | PDF links (share links are converted automatically) |
| `kvStoreFileNames`, `kvStoreId` | PDFs uploaded to an Apify key-value store, as `"storeName/file.pdf"` or `"file.pdf"` + `kvStoreId` |
| `datasetId`, `datasetUrlField` | PDF links taken from another Actor's dataset |
| `mode` | `auto` (default), `invoice` or `tables` |
| `tableDetection` | `auto` (tables with borders, then borderless), `lines` or `text` |
| `parseNumbers` | `true`: `1,234.50`, `1.234,50`, `$12` and `(15.00)` become numbers. Percentages and codes with leading zeros stay text |
| `dateOrder` | `auto`, `DMY` or `MDY`, only for ambiguous dates like `03/04/2026`. Invoice dates are returned as `YYYY-MM-DD` |
| `pdfPassword` | Password for protected PDFs |
| `maxPagesPerDocument`, `maxDocuments`, `maxFileSizeMb` | Limits (0 pages = all) |

### Output fields

| Field | Meaning |
|---|---|
| `status` | `ok`, `no-data` (no table or invoice found, not charged) or `failed` (with `error`, not charged) |
| `rowType` | `invoice-line`, `invoice` (invoice fields found but no item table) or `table-row` |
| `lineCheck` | `ok` when quantity × unit price = amount (discounts allowed), `mismatch`, or `computed` when the amount was missing |
| `totalsCheck` | `ok` when the lines add up to the subtotal (or total) and subtotal + tax = total; `mismatch` means: look at this invoice |
| `otherColumns` | item-table columns that are not one of the standard fields |
| `tableTitle` | the line(s) printed right above a borderless table |
| `tableMethod` | `lines` (table with cell borders) or `text` (aligned columns) |

The `OUTPUT` record has the run summary: PDFs with data, without data and failed, rows, pages charged, the Excel link and all errors.

### Pricing

**Pay per page with data.**

| Event | Price |
|---|---|
| PDF page with data | **$0.006** per page ($6 per 1,000 pages) on the Free plan; $5.50 on Starter, $5 on Scale, $4.50 on Business |

A page is charged only if it produced at least one row (an invoice line, an invoice field or a table row). Cover pages, terms and conditions, scanned pages, failed downloads and files that are not PDFs are **free**. A 1-page invoice costs $0.006; 1,000 two-page invoices cost about $12.

Set a **maximum cost per run** and the Actor reads only the pages that fit, then stops cleanly. **Max pages per PDF** caps long files.

### Use it in n8n, Make or Zapier

Call the Actor with an HTTP request and get the rows back in the same call:

```bash
curl -X POST "https://api.apify.com/v2/acts/egra_van~pdf-invoice-table-extractor/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"urls": [{"url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-eu-2-pages.pdf"}], "mode": "invoice"}'
```

Typical flow: *new invoice PDF in Gmail or Google Drive → this Actor → append the rows to Google Sheets or your accounting tool*, and send invoices with `totalsCheck = mismatch` to a person.

**AI agents** (Claude, ChatGPT, Cursor, n8n AI Agent) can use it through the Apify MCP server: `https://mcp.apify.com?tools=egra_van/pdf-invoice-table-extractor`.

### Limits, said plainly

- **Scanned PDFs (photos or scans without a text layer) are not read.** The Actor reports them as `no-data` and does not charge. If you can, export the PDF from the original program, or OCR it first.
- Invoice fields are found next to their usual labels in English, Romanian, German, French, Dutch, Spanish and Italian (`Invoice No`, `Factura nr`, `Rechnungsnummer`, `Bill to`, `Total due`, `TVA`, `MwSt`...). An unusual layout may leave some fields empty; the line items and table rows still come out.
- The supplier name is taken from a label (`From`, `Supplier`, `Furnizor`...) or, if there is none, from the largest text at the top of page 1.
- Very complex tables (cells merged over several rows and columns) can come out with `col_1`, `col_2`... names instead of the header text. Check `hasHeader`.

### Privacy and personal data

Invoices often contain personal data: names, addresses, tax IDs, bank accounts (IBAN). Here is exactly what happens to them:

- **Where the file goes:** the PDF is downloaded from your link (or read from your key-value store) into your own Apify run and read there. It is not sent to any AI service or other third party, and the Actor keeps no copy outside your run.
- **Where the results stay:** the rows, `OUTPUT.xlsx` and the run log (file names and invoice numbers) are saved in your Apify account, under your account's data retention settings. Delete the run's storage when you no longer need it.
- **The Excel link** in `OUTPUT` opens the file without logging in for anyone who has it. Do not post it publicly.
- **Share links:** a link set to *Anyone with the link* can be opened by anyone who gets it. For confidential invoices, upload the PDFs to a key-value store and use `kvStoreFileNames` instead.
- **The developer of this Actor** does not see your files or results, unless you turn on *Share run data with developers* in your Apify settings.
- You decide which documents you process; make sure you are allowed to process the personal data in them (for example under the GDPR).

### FAQ

**Is my data stored or used for AI training?** No AI service sees your files, and they are not used for training. They are downloaded into your own Apify run; the results stay in your Apify storage under your retention settings (see *Privacy and personal data* above).

**Can it read Word or Excel files?** No, only PDF. For Word, Excel and PowerPoint, use our *Document to Markdown* Actor.

**Why are some numbers text?** Percentages (`21%`), ranges (`61.00 - 94.00`) and codes with leading zeros (`00123`) are kept as written. Turn off `parseNumbers` to keep every cell exactly as printed.

**Where do the sample PDFs come from?** The two invoices are fictional samples made for this Actor (public domain, CC0). The egg price and petroleum reports are public US government documents (USDA AMS and EIA).

# Actor input Schema

## `urls` (type: `array`):

Links to PDF files: invoices, bills, purchase orders, price lists, statistical tables, reports. Google Drive, Dropbox, OneDrive/SharePoint, Box and GitHub share links are converted to direct downloads (share them as 'Anyone with the link').

## `kvStoreFileNames` (type: `array`):

Names of PDF files uploaded to an Apify key-value store. Use 'storeIdOrName/fileName', or just 'fileName' together with the store below (default: this run's store).

## `kvStoreId` (type: `string`):

Store that holds the files above.

## `datasetId` (type: `string`):

Apify dataset (for example the output of a crawler) whose items contain PDF URLs.

## `datasetUrlField` (type: `string`):

Field of the dataset items that holds the PDF URL.

## `mode` (type: `string`):

Auto treats a PDF as an invoice when page 1 says invoice / bill to / factura / Rechnung / facture and an item table or invoice fields are found; otherwise every table becomes rows.

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

Keep 'Auto' unless you get extra small tables you do not need.

## `parseNumbers` (type: `boolean`):

Turn '1,234.50', '1.234,50', '$12.00' and '(15.00)' into numbers (decimal comma or point is detected per document), so they sum correctly in Excel. Percentages and codes with leading zeros stay as text.

## `dateOrder` (type: `string`):

Invoice dates are returned as YYYY-MM-DD. Only matters when day and month are both 12 or less.

## `saveExcel` (type: `boolean`):

Also saves OUTPUT.xlsx in the run's key-value store: a sheet with all invoice lines, a sheet with one row per invoice, and one sheet per table. The dataset itself can be exported to CSV, Excel or JSON as usual.

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

Only for password-protected PDFs (the same password is tried on every file).

## `maxPagesPerDocument` (type: `integer`):

Read only the first N pages of each PDF (0 = all pages).

## `maxDocuments` (type: `integer`):

Maximum number of PDFs in one run.

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

Larger files are skipped (not charged).

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf"
    },
    {
      "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/usda-shell-eggs-2026-10-02.pdf"
    }
  ],
  "datasetUrlField": "url",
  "mode": "auto",
  "tableDetection": "auto",
  "parseNumbers": true,
  "dateOrder": "auto",
  "saveExcel": true,
  "maxPagesPerDocument": 0,
  "maxDocuments": 1000,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

## `invoiceLines` (type: `string`):

One row per invoice line item.

## `tableRows` (type: `string`):

One row per table row.

## `excel` (type: `string`):

OUTPUT.xlsx: invoice lines, invoices and one sheet per table.

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

Counts, pages charged and errors.

# 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 = {
    "urls": [
        {
            "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf"
        },
        {
            "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/usda-shell-eggs-2026-10-02.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("egra_van/pdf-invoice-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 = { "urls": [
        { "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf" },
        { "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/usda-shell-eggs-2026-10-02.pdf" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("egra_van/pdf-invoice-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 '{
  "urls": [
    {
      "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/invoice-us-ruled.pdf"
    },
    {
      "url": "https://raw.githubusercontent.com/Egrarobo/apify-actors/main/pdf-tables-to-rows/samples/usda-shell-eggs-2026-10-02.pdf"
    }
  ]
}' |
apify call egra_van/pdf-invoice-table-extractor --silent --output-dataset

```

## MCP server setup

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