# PDF Table, Invoice & Statement Extractor (XLSX/CSV + MCP) (`forgekit/pdf-table-invoice-extractor`) Actor

Extract geometric multi-page PDF tables to JSON, Markdown, CSV, and formula-safe XLSX plus deterministic invoice and bank statement fields with arithmetic reconciliation and Standby MCP.

- **URL**: https://apify.com/forgekit/pdf-table-invoice-extractor.md
- **Developed by:** [James Edmans](https://apify.com/forgekit) (community)
- **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 $4.20 / 1,000 pdfs analyzed for tables/invoices

This Actor is paid per event and usage. You are charged both the fixed price for specific events and for Apify platform usage.
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 Structured Table & Invoice/Statement Extractor (JSON, CSV, XLSX + MCP)

> **Apify Store Actor:** `forgekit/pdf-table-invoice-extractor` | **Runtime:** Node.js 22 (`pdfjs-dist` + `xlsx` + `csv-stringify`) | **Billing:** Pay-Per-Event (PPE) + Standby MCP Server

### Overview

**PDF Structured Table & Invoice/Statement Extractor** converts digital PDF tables, invoices, receipts, and bank statements into structured JSON records, Markdown tables, formula-safe `.csv` files, and multi-sheet `.xlsx` workbooks — completely deterministically at **zero LLM token cost** and zero external third-party OCR dependency.

Using geometric X/Y text coordinate projection via `pdfjs-dist`, it accurately aligns sparse/empty cells, stitches wrapped multi-line descriptions, merges tables spanning consecutive pages, parses US (`$1,234.56`) and EU (`€1.250,00`) currencies, and runs automated **mathematical reconciliation** (`sum(lineItems) === subtotal`, `subtotal + tax === total`, and bank statement running balances) so finance and automation workflows immediately distinguish 100%-balanced invoices from exceptions.

### Feature Comparison vs. Top Competitors

- **Zero-Charge on Unreadable & HTML-Viewer Failures:** Verifies `%PDF-` magic bytes before parsing; HTML login walls return explicit `status: "error"` with `errorCode: "HTML_INSTEAD_OF_PDF"` and **zero** `pdf-analyzed` or `page-parsed` billing — never returning silent 0-row `"Succeeded"` runs.
- **Automatic Cloud Link Normalization (`normalizeCloudPdfUrl`):** Converts public Google Drive (`/file/d/<ID>/view`), Dropbox (`dl=0` -> `dl=1`), and OneDrive share links into direct binary PDF downloads automatically.
- **Geometric Multi-Page Table Stitching (`mergeContinuedTables`):** Clusters X/Y text coordinates into column projections, preserves empty cells, stitches wrapped lines, and seamlessly merges continued multi-page tables without duplicating headers.
- **Deterministic Invoice & Bank Statement Reconciliation:** Extracts vendor, invoice number, PO number, issue/due dates, VAT ID, IBAN, currency, subtotal, tax rate/amount, total, and line items, then checks arithmetic balance within `±0.02` (`reconciliation.passed`, `discrepancy`, `confidenceScore`).
- **Formula-Safe Excel (`.xlsx`) & CSV Export:** Neutralizes spreadsheet formula injection (`=`, `+`, `-`, `@`) before writing multi-tab `.xlsx` workbooks (1 sheet per table) and `.csv` files to Apify Key-Value Store.
- **Native Standby MCP Server:** Exposes `extract_pdf_tables` and `extract_invoice_fields` for finance AI agents.

| Capability | PDF Table & Invoice Extractor (Ours) | `lergassy/pdf-text-extractor` | `actorzlab/docling-pdf-converter` | `formnexa/invoice-receipt-data-extractor` |
|---|---|---|---|---|
| Geometric Multi-Page Table Stitching | Yes (X-projection + header dedupe) | Basic heuristics | Partial (4 GB RAM, 90.2% success) | No arbitrary multi-page tables |
| Invoice + Bank Statement Schema | Yes (US & EU formats, IBAN, VAT) | No | No | Invoices only (no bank statements) |
| Arithmetic Balance Reconciliation | Yes (`reconciliation.passed` + `discrepancy`) | No | No | No |
| Formula-Safe XLSX & CSV Export | Yes (multi-sheet `.xlsx` + `.csv`) | No | No | No |
| Cloud Share Rewriter + `%PDF-` Guard | Yes (Drive/Dropbox/OneDrive) | No | No | No |
| Standby MCP Server | Native (`/mcp` — 2 tools) | No | No | No |
| Pricing (FREE Tier) | `$0.002` start + `$0.006/pdf` + `$0.002/page` | `$0.003/doc` + `$0.0001/page` | `$0.005/page` + `$0.002/table` | `$0.01/item` |

### Input Configuration

| Field | Type | Required | Default | Description |
|---|---|---|---|---|
| `urls` | `string[]` | No\* | `[]` | Public PDF URLs (SSRF-protected, up to 200). |
| `normalizeCloudPdfUrl` | `boolean` | No | `true` | Auto-convert public Google Drive, Dropbox, and OneDrive share links to direct PDF downloads. |
| `base64Pdfs` | `object[]` | No\* | `[]` | Inline PDFs `[{ "filename": "invoice.pdf", "dataBase64": "..." }]` (up to 50). |
| `kvsKeys` | `string[]` | No\* | `[]` | Binary PDF keys in Apify Key-Value Store (up to 200). |
| `sourceKeyValueStoreId` | `string` | No | `""` | Optional external Apify KVS ID for `kvsKeys`. |
| `inputDatasetId` | `string` | No\* | `""` | Upstream Apify Dataset ID to pull PDF URLs from. |
| `datasetUrlField` | `string` | No | `"url"` | URL field inside `inputDatasetId`. |
| `mode` | `string` | No | `"both"` | `"tables-only"`, `"invoice-statement"`, or `"both"`. |
| `pageRange` | `string` | No | `""` | Optional 1-indexed page subset e.g. `"1-10"`. |
| `maxPages` | `integer` | No | `100` | Maximum pages parsed per PDF (`1–1000`). |
| `password` | `string` | No | `""` | Optional secret password for encrypted PDFs (`isSecret: true`). |
| `rowTolerancePt` | `number` | No | `3.5` | Vertical Y-clustering tolerance in PDF points (`1–20`). |
| `columnGapThresholdPt` | `number` | No | `12` | Minimum horizontal gap in points separating adjacent columns (`3–100`). |
| `minTableRows` | `integer` | No | `2` | Minimum rows required to emit a table (`2–50`). |
| `minTableColumns` | `integer` | No | `2` | Minimum columns required to emit a table (`2–30`). |
| `mergeContinuedTables` | `boolean` | No | `true` | Merge tables continuing across consecutive pages with matching column geometry. |
| `exportTablesToXlsx` | `boolean` | No | `true` | Write formula-safe multi-sheet `.xlsx` workbook to KV store. |
| `exportTablesToCsv` | `boolean` | No | `false` | Write each table as a formula-safe `.csv` file to KV store. |
| `maxConcurrency` | `integer` | No | `4` | Concurrent PDF workers (`1–15`). |
| `maxPdfSizeMb` | `number` | No | `30` | Maximum PDF download/base64 size in MB (`1–150`). |
| `timeoutSecs` | `integer` | No | `30` | Per-PDF timeout in seconds (`5–180`). |

*\*At least one input source (`urls`, `base64Pdfs`, `kvsKeys`, or `inputDatasetId`) is required.*

### Output Example

Below is an exact real output record captured from running this Actor locally:

```json
{
  "source": "invoice-2026-0042.pdf",
  "filename": "invoice-2026-0042.pdf",
  "status": "ok",
  "pageCount": 1,
  "pagesParsed": 1,
  "tablesCount": 1,
  "tables": [
    {
      "tableIndex": 0,
      "pages": [1],
      "headers": ["Description", "Qty", "Unit Price", "Amount"],
      "rows": [
        ["Cloud Hosting", "2", "$150.00", "$300.00"],
        ["Support Plan", "1", "$200.00", "$200.00"]
      ],
      "records": [
        { "Description": "Cloud Hosting", "Qty": "2", "Unit Price": "$150.00", "Amount": "$300.00" },
        { "Description": "Support Plan", "Qty": "1", "Unit Price": "$200.00", "Amount": "$200.00" }
      ],
      "markdown": "| Description | Qty | Unit Price | Amount |\n| --- | --- | --- | --- |\n| Cloud Hosting | 2 | $150.00 | $300.00 |\n| Support Plan | 1 | $200.00 | $200.00 |"
    }
  ],
  "invoiceData": {
    "documentType": "invoice",
    "invoiceNumber": "INV-2026-0042",
    "poNumber": null,
    "issueDate": "2026-11-15",
    "dueDate": "2026-12-15",
    "currency": "USD",
    "vendorName": "Acme Cloud Ltd",
    "vendorVatId": "GB123456789",
    "iban": "DE89370400440532013000",
    "subtotal": 500,
    "taxRate": 20,
    "taxAmount": 100,
    "totalAmount": 600,
    "lineItems": [
      { "description": "Cloud Hosting", "quantity": 2, "unitPrice": 150, "lineTotal": 300 },
      { "description": "Support Plan", "quantity": 1, "unitPrice": 200, "lineTotal": 200 }
    ],
    "transactions": [],
    "reconciliation": {
      "lineItemsSum": 500,
      "expectedTotal": 600,
      "passed": true,
      "discrepancy": 0,
      "checks": [
        "lineItemsSum (500) == subtotal (500)",
        "expectedTotal (600) == totalAmount (600)"
      ]
    },
    "confidenceScore": 1
  },
  "exportedXlsxKey": "tables-invoice-2026-0042-0.xlsx",
  "exportedCsvKeys": [],
  "errorCode": null,
  "error": null
}
```

### Pay-Per-Event (PPE) Pricing

| Event Key | Event Title | Price (USD) | Billing Trigger |
|---|---|---:|---|
| `actor-start` | Actor run start | `$0.002` | Charged once per batch run that analyzes at least one valid PDF. |
| `pdf-analyzed` | PDF analyzed for tables/invoices | `$0.006` | Charged per valid PDF successfully parsed (never billed on HTML pages or corrupt files). |
| `page-parsed` | PDF page parsed for tables | `$0.002` | Charged per page parsed from a valid PDF. |
| `mcp-tool-call` | Standby MCP tool execution | `$0.005` | Charged per successful Standby MCP tool call. |

**Illustrative Cost Example:** Extracting tables & invoices from `100` two-page PDFs (200 pages) costs `$0.002 + (100 * $0.006) + (200 * $0.002) = $1.002 USD`.

### Standby MCP Server & AI Agent Integration

Connect `forgekit/pdf-table-invoice-extractor` in Apify Standby Mode (`APIFY_META_ORIGIN=STANDBY`) to expose two structured finance tools over Streamable HTTP / SSE:

- **Health endpoint:** `GET /health`
- **MCP endpoint:** `POST /mcp` and `GET /mcp`
- **Exposed MCP tools:** `extract_pdf_tables`, `extract_invoice_fields`

```json
{
  "mcpServers": {
    "pdf-table-invoice-extractor": {
      "url": "https://forgekit--pdf-table-invoice-extractor.apify.actor/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_APIFY_TOKEN"
      }
    }
  }
}
```

### Error Handling, Rate Limits & Limitations

- **SSRF & Payload Hardening:** Only public `http:`/`https:` URLs are allowed (loopback, RFC1918, and cloud metadata IPs are blocked before connect and across redirects). Download size is capped by `maxPdfSizeMb`.
- **Zero-Charge Partial Resilience:** Corrupt PDFs, 404 URLs, and HTML viewer pages emit `status: "error"` with explicit `errorCode` (`HTML_INSTEAD_OF_PDF`, `INVALID_PDF_HEADER`, `HTTP_ERROR`, `SSRF_BLOCKED`) and zero `pdf-analyzed` / `page-parsed` charges.
- **Scope:** Designed for digital text-layer PDFs (invoices, accounting exports, bank statements, reports). For image-only scanned PDFs, run our **Bulk Image & Scanned-PDF OCR Engine** first.

### Quick Start & Example Input

#### 1. Run in Apify Console (No Code)

1. Open **[`forgekit/pdf-table-invoice-extractor`](https://apify.com/forgekit/pdf-table-invoice-extractor)** in Apify Console and click **Try for free**.
2. Paste or adjust the ready-to-run input JSON below (safe defaults are pre-filled).
3. Click **Start** and export results as **JSON, CSV, Excel, or NDJSON** from the **Output** tab.

```json
{
  "mode": "both"
}
```

#### 2. Run via API (`apify-client` — Node.js & Python)

```javascript
import { ApifyClient } from 'apify-client';

const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('forgekit/pdf-table-invoice-extractor').call({"mode":"both"});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

```python
from apify_client import ApifyClient
import os

client = ApifyClient(os.environ["APIFY_TOKEN"])
run = client.actor("forgekit/pdf-table-invoice-extractor").call(run_input={"mode":"both"})
items = list(client.dataset(run["defaultDatasetId"]).iterate_items())
print(items)
```

#### 3. Connect to n8n, Make, Zapier & Webhooks

- **n8n / Make / Zapier:** Add the official **Apify** module, choose **Run Actor**, select `forgekit/pdf-table-invoice-extractor`, and pass the JSON payload above.
- **Schedules & Webhooks:** Attach an Apify Schedule for recurring runs and trigger downstream webhooks automatically on `ACTOR.RUN.SUCCEEDED`.

### Use Cases — What Can You Do With This Data?

- **Document & Invoice Ingestion Pipelines:** Automate PDF, OCR, table, or media extraction with **PDF Structured Table & Invoice/Statement Extractor (JSON, CSV, XLSX + MCP)** to feed accounting systems, ERPs, legal archives, and AI knowledge bases.
- **E-Commerce & Content Operations:** Process product images, generate pixel-perfect PDFs/screenshots, transcode media, or create/decode barcodes at scale via API without managing local FFmpeg or Chromium servers.
- **AI Vision & Multimodal Agent Workflows:** Convert raw PDFs, videos, podcasts, or webpages into clean Markdown, keyframes, transcripts, or optimized thumbnails ready for multimodal LLMs.
- **Automated QA & Visual Monitoring:** Schedule recurring captures or document checks and export structured metadata + KV Store artifacts directly into Slack, S3, Make, or n8n.

### Frequently Asked Questions (FAQ)

#### How much does PDF Structured Table & Invoice/Statement Extractor (JSON, CSV, XLSX + MCP) cost to run?

You only pay for actual output via transparent Pay-Per-Event billing (starting at `$0.006` per `pdf-analyzed` (PDF analyzed for tables/invoices); see the PPE Pricing table above). Runs that produce zero billable results or fail upstream incur **`$0.00`** — including zero `actor-start` fee — and Apify's built-in **Max total charge** (`ACTOR_MAX_TOTAL_CHARGE_USD`) hard-caps spend automatically.

#### Does this Actor require proxies, logins, or CAPTCHA solving?

No. This Actor executes deterministic document/media processing locally inside the Apify container (Node.js 22, Sharp, PDF engines, FFmpeg, or Chromium where required) on files and URLs you supply, with strict SSRF protection blocking private/metadata IP ranges.

#### What export formats and integrations are supported?

Every run stores structured results in an Apify Dataset downloadable as **JSON, CSV, Excel (XLSX), NDJSON, XML, or HTML Table** via Console or REST API, plus native connectors for **n8n, Make, Zapier, Google Sheets, Airtable, Slack, and webhooks**.

#### Can AI agents (Claude Desktop, Cursor, ChatGPT, LangChain) call this Actor directly via MCP?

Yes! **PDF Structured Table & Invoice/Statement Extractor (JSON, CSV, XLSX + MCP)** includes a built-in **Standby MCP Server** at `https://forgekit--pdf-table-invoice-extractor.apify.actor/mcp` supporting JSON-RPC 2.0 (`initialize`, `ping`, `tools/list`, `tools/call`) with Claude-compliant `^[a-zA-Z0-9_.-]{1,64}$` tool schemas.

#### Do I need to provide an API key (`password`)?

All sensitive key fields (`password`) are optional BYOK upgrades marked `isSecret: true` — they are encrypted at rest by Apify and never echoed into datasets, KV summaries, or logs.

#### How fast and lightweight is it compared to browser scrapers?

It runs on lightweight **Node.js 22** (256–512 MB RAM, zero headless browser) so typical runs finish in seconds with high reliability and low platform compute cost.

### Related `forgekit` Actors

Explore companion Actors in **Media, Document & PDF Processing** and core ETL utilities to chain end-to-end pipelines:

| Actor | Store Slug | Mode |
|---|---|---|
| [PDF-to-Markdown, Clean Text & Metadata Extractor (LLM & RAG Ready + MCP)](https://apify.com/forgekit/pdf-to-markdown-text-extractor) | `forgekit/pdf-to-markdown-text-extractor` | ✅ Standby MCP |
| [PDF Toolkit: Bulk Merge, Split, Compress, Watermark, Rotate & Form Reader](https://apify.com/forgekit/pdf-toolkit-merge-split-watermark) | `forgekit/pdf-toolkit-merge-split-watermark` | Batch REST API |
| [Bulk Image & Scanned-PDF OCR Engine (Multi-Language + Word Bounding Boxes + MCP)](https://apify.com/forgekit/bulk-image-pdf-ocr-engine) | `forgekit/bulk-image-pdf-ocr-engine` | ✅ Standby MCP |
| [HTML, Markdown & URL to Pixel-Perfect PDF & Invoice Renderer](https://apify.com/forgekit/html-markdown-url-to-pdf-renderer) | `forgekit/html-markdown-url-to-pdf-renderer` | Batch REST API |
| [Multi-Device Website Screenshot API (Desktop/Tablet/Mobile Matrix, Dark Mode, Visual Diff + MCP)](https://apify.com/forgekit/multi-device-website-screenshot-api) | `forgekit/multi-device-website-screenshot-api` | ✅ Standby MCP |
| [Dataset Merge, Fuzzy Dedupe & Cross-Join Pro](https://apify.com/forgekit/dataset-merge-dedupe-pro) | `forgekit/dataset-merge-dedupe-pro` | ✅ Standby MCP |
| [Dataset Diff & Change Detector (Added / Removed / Modified)](https://apify.com/forgekit/dataset-diff-change-detector) | `forgekit/dataset-diff-change-detector` | ✅ Standby MCP |

# Actor input Schema

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

Public PDF URLs (SSRF-protected). Automatically rewrites Google Drive, Dropbox, and OneDrive share links when normalizeCloudPdfUrl is enabled.

## `normalizeCloudPdfUrl` (type: `boolean`):

Automatically rewrite public Google Drive, Dropbox (dl=0 to dl=1), and OneDrive share URLs into direct PDF download links.

## `base64Pdfs` (type: `array`):

Inline PDFs as \[{ "filename": "invoice.pdf", "dataBase64": "JVBERi0x..." }].

## `kvsKeys` (type: `array`):

Binary PDF keys stored in the default or source Key-Value Store.

## `sourceStoreId` (type: `string`):

Optional Apify Key-Value Store ID to read kvsKeys from.

## `inputDatasetId` (type: `string`):

Optional upstream Apify Dataset ID containing PDF URLs.

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

Field name containing the PDF URL in inputDatasetId.

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

Choose whether to extract geometric tables, structured invoice/statement fields, or both.

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

Optional 1-indexed page subset such as "1-10" or "1,3-5".

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

Safety cap on pages parsed per PDF.

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

Optional password for encrypted PDFs.

## `rowTolerancePt` (type: `number`):

Vertical Y-coordinate clustering tolerance in PDF points for grouping text spans into rows.

## `columnGapThresholdPt` (type: `number`):

Minimum horizontal gap in PDF points separating adjacent table columns.

## `minTableRows` (type: `integer`):

Minimum number of rows required to accept a detected block as a table.

## `minTableColumns` (type: `integer`):

Minimum number of columns required to accept a detected block as a table.

## `mergeContinuedTables` (type: `boolean`):

Automatically stitch tables continuing across consecutive pages with matching column signatures.

## `exportTablesToXlsx` (type: `boolean`):

Save a multi-sheet formula-safe .xlsx workbook (1 sheet per table) to Key-Value Store.

## `exportTablesToCsv` (type: `boolean`):

Save each extracted table as a formula-safe .csv file in Key-Value Store.

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

Maximum number of PDFs processed in parallel.

## `maxPdfSizeMb` (type: `number`):

Maximum allowed file size per PDF in megabytes.

## `timeoutSecs` (type: `integer`):

Per-PDF download and parse timeout in seconds.

## Actor input object example

```json
{
  "urls": [],
  "normalizeCloudPdfUrl": true,
  "base64Pdfs": [
    {
      "filename": "acme-sample-invoice.pdf",
      "dataBase64": "JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA0IDAgUiA+PiA+PiAvQ29udGVudHMgNSAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+CmVuZG9iago1IDAgb2JqCjw8IC9MZW5ndGggNjkxID4+CnN0cmVhbQpCVAovRjEgMTIgVGYKMSAwIDAgMSA3MiA3MzAgVG0gKEFDTUUgQ0xPVUQgU1lTVEVNUyBMVEQpIFRqCjEgMCAwIDEgNzIgNzA2IFRtIChJTlZPSUNFICNJTlYtMjAyNi0xMDQyKSBUagoxIDAgMCAxIDcyIDY4NCBUbSAoRGF0ZTogMjAyNi0xMi0wMSAgIER1ZSBEYXRlOiAyMDI2LTEyLTMxKSBUagoxIDAgMCAxIDcyIDY0NCBUbSAoRGVzY3JpcHRpb24pIFRqCjEgMCAwIDEgMzAwIDY0NCBUbSAoUXR5KSBUagoxIDAgMCAxIDM4MCA2NDQgVG0gKFVuaXQgUHJpY2UpIFRqCjEgMCAwIDEgNDgwIDY0NCBUbSAoQW1vdW50KSBUagoxIDAgMCAxIDcyIDYyMCBUbSAoRW50ZXJwcmlzZSBBUEkgUGxhbikgVGoKMSAwIDAgMSAzMDAgNjIwIFRtICgyKSBUagoxIDAgMCAxIDM4MCA2MjAgVG0gKCQxNTAuMDApIFRqCjEgMCAwIDEgNDgwIDYyMCBUbSAoJDMwMC4wMCkgVGoKMSAwIDAgMSA3MiA1OTYgVG0gKFByaW9yaXR5IFN1cHBvcnQgQWRkLW9uKSBUagoxIDAgMCAxIDMwMCA1OTYgVG0gKDEpIFRqCjEgMCAwIDEgMzgwIDU5NiBUbSAoJDc1LjAwKSBUagoxIDAgMCAxIDQ4MCA1OTYgVG0gKCQ3NS4wMCkgVGoKMSAwIDAgMSAzODAgNTU2IFRtIChTdWJ0b3RhbCkgVGoKMSAwIDAgMSA0ODAgNTU2IFRtICgkMzc1LjAwKSBUagoxIDAgMCAxIDM4MCA1MzQgVG0gKFRvdGFsKSBUagoxIDAgMCAxIDQ4MCA1MzQgVG0gKCQzNzUuMDApIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDAzMTEgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoxMDUyCiUlRU9GCg=="
    }
  ],
  "kvsKeys": [],
  "sourceStoreId": "",
  "inputDatasetId": "",
  "datasetUrlField": "url",
  "mode": "both",
  "pageRange": "",
  "maxPages": 100,
  "rowTolerancePt": 3.5,
  "columnGapThresholdPt": 12,
  "minTableRows": 2,
  "minTableColumns": 2,
  "mergeContinuedTables": true,
  "exportTablesToXlsx": true,
  "exportTablesToCsv": false,
  "maxConcurrency": 4,
  "maxPdfSizeMb": 30,
  "timeoutSecs": 30
}
```

# Actor output Schema

## `dataset` (type: `string`):

No description

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

No description

## `runSummary` (type: `string`):

No description

## `ppeLedger` (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 = {
    "base64Pdfs": [
        {
            "filename": "acme-sample-invoice.pdf",
            "dataBase64": "JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA0IDAgUiA+PiA+PiAvQ29udGVudHMgNSAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+CmVuZG9iago1IDAgb2JqCjw8IC9MZW5ndGggNjkxID4+CnN0cmVhbQpCVAovRjEgMTIgVGYKMSAwIDAgMSA3MiA3MzAgVG0gKEFDTUUgQ0xPVUQgU1lTVEVNUyBMVEQpIFRqCjEgMCAwIDEgNzIgNzA2IFRtIChJTlZPSUNFICNJTlYtMjAyNi0xMDQyKSBUagoxIDAgMCAxIDcyIDY4NCBUbSAoRGF0ZTogMjAyNi0xMi0wMSAgIER1ZSBEYXRlOiAyMDI2LTEyLTMxKSBUagoxIDAgMCAxIDcyIDY0NCBUbSAoRGVzY3JpcHRpb24pIFRqCjEgMCAwIDEgMzAwIDY0NCBUbSAoUXR5KSBUagoxIDAgMCAxIDM4MCA2NDQgVG0gKFVuaXQgUHJpY2UpIFRqCjEgMCAwIDEgNDgwIDY0NCBUbSAoQW1vdW50KSBUagoxIDAgMCAxIDcyIDYyMCBUbSAoRW50ZXJwcmlzZSBBUEkgUGxhbikgVGoKMSAwIDAgMSAzMDAgNjIwIFRtICgyKSBUagoxIDAgMCAxIDM4MCA2MjAgVG0gKCQxNTAuMDApIFRqCjEgMCAwIDEgNDgwIDYyMCBUbSAoJDMwMC4wMCkgVGoKMSAwIDAgMSA3MiA1OTYgVG0gKFByaW9yaXR5IFN1cHBvcnQgQWRkLW9uKSBUagoxIDAgMCAxIDMwMCA1OTYgVG0gKDEpIFRqCjEgMCAwIDEgMzgwIDU5NiBUbSAoJDc1LjAwKSBUagoxIDAgMCAxIDQ4MCA1OTYgVG0gKCQ3NS4wMCkgVGoKMSAwIDAgMSAzODAgNTU2IFRtIChTdWJ0b3RhbCkgVGoKMSAwIDAgMSA0ODAgNTU2IFRtICgkMzc1LjAwKSBUagoxIDAgMCAxIDM4MCA1MzQgVG0gKFRvdGFsKSBUagoxIDAgMCAxIDQ4MCA1MzQgVG0gKCQzNzUuMDApIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDAzMTEgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoxMDUyCiUlRU9GCg=="
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forgekit/pdf-table-invoice-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 = { "base64Pdfs": [{
            "filename": "acme-sample-invoice.pdf",
            "dataBase64": "JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA0IDAgUiA+PiA+PiAvQ29udGVudHMgNSAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+CmVuZG9iago1IDAgb2JqCjw8IC9MZW5ndGggNjkxID4+CnN0cmVhbQpCVAovRjEgMTIgVGYKMSAwIDAgMSA3MiA3MzAgVG0gKEFDTUUgQ0xPVUQgU1lTVEVNUyBMVEQpIFRqCjEgMCAwIDEgNzIgNzA2IFRtIChJTlZPSUNFICNJTlYtMjAyNi0xMDQyKSBUagoxIDAgMCAxIDcyIDY4NCBUbSAoRGF0ZTogMjAyNi0xMi0wMSAgIER1ZSBEYXRlOiAyMDI2LTEyLTMxKSBUagoxIDAgMCAxIDcyIDY0NCBUbSAoRGVzY3JpcHRpb24pIFRqCjEgMCAwIDEgMzAwIDY0NCBUbSAoUXR5KSBUagoxIDAgMCAxIDM4MCA2NDQgVG0gKFVuaXQgUHJpY2UpIFRqCjEgMCAwIDEgNDgwIDY0NCBUbSAoQW1vdW50KSBUagoxIDAgMCAxIDcyIDYyMCBUbSAoRW50ZXJwcmlzZSBBUEkgUGxhbikgVGoKMSAwIDAgMSAzMDAgNjIwIFRtICgyKSBUagoxIDAgMCAxIDM4MCA2MjAgVG0gKCQxNTAuMDApIFRqCjEgMCAwIDEgNDgwIDYyMCBUbSAoJDMwMC4wMCkgVGoKMSAwIDAgMSA3MiA1OTYgVG0gKFByaW9yaXR5IFN1cHBvcnQgQWRkLW9uKSBUagoxIDAgMCAxIDMwMCA1OTYgVG0gKDEpIFRqCjEgMCAwIDEgMzgwIDU5NiBUbSAoJDc1LjAwKSBUagoxIDAgMCAxIDQ4MCA1OTYgVG0gKCQ3NS4wMCkgVGoKMSAwIDAgMSAzODAgNTU2IFRtIChTdWJ0b3RhbCkgVGoKMSAwIDAgMSA0ODAgNTU2IFRtICgkMzc1LjAwKSBUagoxIDAgMCAxIDM4MCA1MzQgVG0gKFRvdGFsKSBUagoxIDAgMCAxIDQ4MCA1MzQgVG0gKCQzNzUuMDApIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDAzMTEgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoxMDUyCiUlRU9GCg==",
        }] }

# Run the Actor and wait for it to finish
run = client.actor("forgekit/pdf-table-invoice-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 '{
  "base64Pdfs": [
    {
      "filename": "acme-sample-invoice.pdf",
      "dataBase64": "JVBERi0xLjQKMSAwIG9iago8PCAvVHlwZSAvQ2F0YWxvZyAvUGFnZXMgMiAwIFIgPj4KZW5kb2JqCjIgMCBvYmoKPDwgL1R5cGUgL1BhZ2VzIC9LaWRzIFszIDAgUl0gL0NvdW50IDEgPj4KZW5kb2JqCjMgMCBvYmoKPDwgL1R5cGUgL1BhZ2UgL1BhcmVudCAyIDAgUiAvTWVkaWFCb3ggWzAgMCA2MTIgNzkyXSAvUmVzb3VyY2VzIDw8IC9Gb250IDw8IC9GMSA0IDAgUiA+PiA+PiAvQ29udGVudHMgNSAwIFIgPj4KZW5kb2JqCjQgMCBvYmoKPDwgL1R5cGUgL0ZvbnQgL1N1YnR5cGUgL1R5cGUxIC9CYXNlRm9udCAvSGVsdmV0aWNhID4+CmVuZG9iago1IDAgb2JqCjw8IC9MZW5ndGggNjkxID4+CnN0cmVhbQpCVAovRjEgMTIgVGYKMSAwIDAgMSA3MiA3MzAgVG0gKEFDTUUgQ0xPVUQgU1lTVEVNUyBMVEQpIFRqCjEgMCAwIDEgNzIgNzA2IFRtIChJTlZPSUNFICNJTlYtMjAyNi0xMDQyKSBUagoxIDAgMCAxIDcyIDY4NCBUbSAoRGF0ZTogMjAyNi0xMi0wMSAgIER1ZSBEYXRlOiAyMDI2LTEyLTMxKSBUagoxIDAgMCAxIDcyIDY0NCBUbSAoRGVzY3JpcHRpb24pIFRqCjEgMCAwIDEgMzAwIDY0NCBUbSAoUXR5KSBUagoxIDAgMCAxIDM4MCA2NDQgVG0gKFVuaXQgUHJpY2UpIFRqCjEgMCAwIDEgNDgwIDY0NCBUbSAoQW1vdW50KSBUagoxIDAgMCAxIDcyIDYyMCBUbSAoRW50ZXJwcmlzZSBBUEkgUGxhbikgVGoKMSAwIDAgMSAzMDAgNjIwIFRtICgyKSBUagoxIDAgMCAxIDM4MCA2MjAgVG0gKCQxNTAuMDApIFRqCjEgMCAwIDEgNDgwIDYyMCBUbSAoJDMwMC4wMCkgVGoKMSAwIDAgMSA3MiA1OTYgVG0gKFByaW9yaXR5IFN1cHBvcnQgQWRkLW9uKSBUagoxIDAgMCAxIDMwMCA1OTYgVG0gKDEpIFRqCjEgMCAwIDEgMzgwIDU5NiBUbSAoJDc1LjAwKSBUagoxIDAgMCAxIDQ4MCA1OTYgVG0gKCQ3NS4wMCkgVGoKMSAwIDAgMSAzODAgNTU2IFRtIChTdWJ0b3RhbCkgVGoKMSAwIDAgMSA0ODAgNTU2IFRtICgkMzc1LjAwKSBUagoxIDAgMCAxIDM4MCA1MzQgVG0gKFRvdGFsKSBUagoxIDAgMCAxIDQ4MCA1MzQgVG0gKCQzNzUuMDApIFRqCkVUCmVuZHN0cmVhbQplbmRvYmoKeHJlZgowIDYKMDAwMDAwMDAwMCA2NTUzNSBmIAowMDAwMDAwMDA5IDAwMDAwIG4gCjAwMDAwMDAwNTggMDAwMDAgbiAKMDAwMDAwMDExNSAwMDAwMCBuIAowMDAwMDAwMjQxIDAwMDAwIG4gCjAwMDAwMDAzMTEgMDAwMDAgbiAKdHJhaWxlcgo8PCAvU2l6ZSA2IC9Sb290IDEgMCBSID4+CnN0YXJ0eHJlZgoxMDUyCiUlRU9GCg=="
    }
  ]
}' |
apify call forgekit/pdf-table-invoice-extractor --silent --output-dataset

```

## MCP server setup

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