# Invoice & Statement PDF to Rows (`toolkitlabs/invoice-pdf-to-rows`) Actor

Turn invoice and bank-statement PDFs you already have into structured rows. Scanned pages are reported, never guessed.

- **URL**: https://apify.com/toolkitlabs/invoice-pdf-to-rows.md
- **Developed by:** [Toolkit Labs](https://apify.com/toolkitlabs) (community)
- **Categories:** Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$20.00 / 1,000 page parseds

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Invoice & Statement PDF to Rows

**What it got wrong, first, because that is what you need to price the risk.** On a held-out set of
**13 real vendor invoices** taken from a public MIT-licensed test corpus (Amazon Web Services, Flipkart,
Coolblue x2, Free, OYO, Saeco, QualityHosting, Netpresse, Azure Interior and three others), scored **once**
and never tuned afterwards: **9 of 13 produced line items with parsed amounts; 4 of 13 did not** — those four
fell back to raw table rows, which is useful output but not parsed line items. On **7 non-invoice control
documents** run through the same pass, **6 were reported correctly** (5 as `unreadable`, no text layer) and
**1 produced 4 `invoice_line` rows that should not exist** — a Google-Docs export whose text happens to look
like line items. Run: 20 documents, 22 pages, **176 rows, 16 pages parsed, 6 pages unreadable, 0 fetch failures.**

### What it does

You give it direct HTTPS links to PDF files **you already have**. It downloads exactly those files and turns
each page into rows:

- `invoice_line` — description, amount, quantity, plus the document's invoice number, date, currency, VAT rate,
  VAT amount and total.
- `statement_txn` — date, description, amount and running balance, one row per transaction line.
- `table_row` — every cell of a detected table grid, when the page is a table rather than a document.
- `unreadable` — **a page with no text layer is never guessed at.** It is reported with the warning
  `scanned-page-no-text-layer` and **it is not charged.**

Nothing is crawled, searched or scraped. No third-party site is visited, no account is needed, no API key,
no proxy, no model call. Every number is returned as a normalised string (`1.234,56 EUR` becomes `1234.56`
with `currency: EUR`), never a rounded float.

### Price

**One charged event: `page-parsed`, $0.02 per page that yielded at least one row.** A page with no text
layer fires **no event at all** — it appears in your results as `unreadable` and it costs nothing. (Apify's
pricing model will not accept an event priced at zero, so the refusal is free by never being charged rather
than by being charged $0.00.)

### What it does not do (v1)

- **No OCR.** A scanned page is refused, not interpreted.
- Ambiguous dates: `01/07/2026` is read day-first and the row carries the warning `assumed-day-first-date`.
  It is stated, never hidden.
- No dashboard, no webhook, no storage beyond the run's own dataset.

### Input

```json
{ "pdfUrls": ["<a direct https link to your own PDF>"], "mode": "auto", "maxPages": 0 }
```

`mode` is `auto` (detect per page), `invoice`, `statement` or `table`. `pdfUrls` takes 1-200 links.

### Honesty notes

The 46-check selftest runs inside the Docker build, so a build that succeeded is a selftest that passed.
The held-out scores above were produced by one run against files this actor had never seen, and the parser
has not been changed since that run. `n=13` invoices is a small set and is quoted as a count, never as a rate.

# Actor input Schema

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

1-200 direct HTTPS links to PDF files you already have. Nothing is crawled or searched: the actor downloads exactly the files you list. A page with a text layer becomes rows; a scanned page is reported as unreadable and is not charged.

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

auto detects invoice vs statement per page. Force one if you already know.

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

Stop after this many pages of each document. 0 means every page.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.hydro.mb.ca/accounts_and_services/pdf/sample_bill.pdf"
  ],
  "mode": "auto",
  "maxPages": 0
}
```

# Actor output Schema

## `rows` (type: `string`):

One dataset item per detected row: sourceUrl, page, kind (invoice\_line, statement\_txn, table\_row or unreadable), fields, confidence, extractor and warnings.

# 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": [
        "https://www.hydro.mb.ca/accounts_and_services/pdf/sample_bill.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("toolkitlabs/invoice-pdf-to-rows").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": ["https://www.hydro.mb.ca/accounts_and_services/pdf/sample_bill.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("toolkitlabs/invoice-pdf-to-rows").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": [
    "https://www.hydro.mb.ca/accounts_and_services/pdf/sample_bill.pdf"
  ]
}' |
apify call toolkitlabs/invoice-pdf-to-rows --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,toolkitlabs/invoice-pdf-to-rows"
        }
    }
}

```

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/wzlaq56ETdz4H9jIW/builds/zikzVoCgqgYgs6X66/openapi.json
