# PDF Tables to CSV & JSON - every table, every page (`forge_creations/pdf-tables-to-csv`) Actor

Paste PDF links; get every table back as rows, header-keyed JSON records and CSV, with page number and position. Finds ruled and unruled tables. $2 per 1,000 tables; pages without tables are free.

- **URL**: https://apify.com/forge_creations/pdf-tables-to-csv.md
- **Developed by:** [Forge Creations](https://apify.com/forge_creations) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 table extracteds

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

## PDF Tables to CSV & JSON: every table, every page

Paste links to PDFs. You get **every table** back, ready to use:

- `rows`: the table as a list of rows
- `records`: one JSON object per row, keyed by the header row
- `csv`: the same table as CSV text, ready for a spreadsheet
- `page`, `table_index` and `bbox` so you know where each table came from

It finds **ruled tables** (drawn grid lines) and **unruled tables** (columns lined up with spaces), and drops page titles and footnotes that sit next to a table. Each row says how the table was found.

### Pricing

| What | Price |
|---|---|
| Table extracted | $0.002 ($2 per 1,000 tables) |
| Apify start fee | $0.00005 per run |

Pages without tables, scanned pages, failed downloads and non-PDF files are **not charged**. Set a maximum charge in run options to cap spending.

### Input

| Field | Default | Notes |
|---|---|---|
| fileUrls | required | Public http(s) links to PDFs, 50 MB max each |
| pages | all | e.g. `1-3,7` |
| maxPagesPerFile | 200 | Pages read per PDF |
| strategy | auto | `auto`, `lines` (ruled only) or `text` (aligned only) |
| firstRowIsHeader | true | Column names for `records` |

### Output (one row per table)

`source_url, page, pages_total, table_index, detected_by, n_rows, n_cols, header, rows, records, csv, bbox, status`

Files without tables return one free row with `status: no_tables` and a note.

### Limits

- Scanned PDFs have no text layer, so there is nothing to read as a table. Run them through **PDF & Image to Text** (OCR) first.
- Merged cells come back in the first cell they cover; the other cells are empty.
- Unruled tables with multi-line headers can split header words across columns; the data rows are usually clean. Check `detected_by`.
- Very complex layouts (nested tables, rotated text) may need the `lines` or `text` setting.

### Works well with

- **n8n, Make, Zapier**: call it per PDF and map `records` straight into your sheet or database.
- **PDF & Image to Text** from the same developer for the text around the tables.

### Support

Open an issue on the Issues tab with the PDF URL (if shareable) and the run ID.

# Actor input Schema

## `fileUrls` (type: `array`):

Public http(s) links to PDF files, max 50 MB each.

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

Which pages to read, e.g. 1-3,7. Leave empty for all pages (up to the limit below).

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

Read at most this many pages from each PDF.

## `strategy` (type: `string`):

Auto tries ruled tables first and falls back to text-aligned columns when a page has no usable ruling.

## `firstRowIsHeader` (type: `boolean`):

Use each table's first row as column names for the JSON records.

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

How many PDFs are processed in parallel.

## Actor input object example

```json
{
  "fileUrls": [
    "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf",
    "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/background_lines.pdf"
  ],
  "maxPagesPerFile": 200,
  "strategy": "auto",
  "firstRowIsHeader": true,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

One row per table: page, table number, rows, header-keyed records and CSV text. Free status rows for files or pages without tables.

# 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 = {
    "fileUrls": [
        "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf",
        "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/background_lines.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forge_creations/pdf-tables-to-csv").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 = { "fileUrls": [
        "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf",
        "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/background_lines.pdf",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("forge_creations/pdf-tables-to-csv").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 '{
  "fileUrls": [
    "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/foo.pdf",
    "https://raw.githubusercontent.com/camelot-dev/camelot/master/docs/_static/pdf/background_lines.pdf"
  ]
}' |
apify call forge_creations/pdf-tables-to-csv --silent --output-dataset

```

## MCP server setup

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

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/OipDGoTcHicv2n23l/builds/nGGdInRs6s2VfKoS6/openapi.json
