# PDF Table to Excel & CSV (`adhistory/pdf-tables-to-excel`) Actor

Extract tables from PDF links into rows, one Excel file per PDF and a CSV per table. Tables that run across pages are joined into one. Billed only for tables delivered: $2 per 1,000.

- **URL**: https://apify.com/adhistory/pdf-tables-to-excel.md
- **Developed by:** [Brandon Ob](https://apify.com/adhistory) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 tables

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 Table to Excel & CSV: extract tables from PDF links

Paste links to PDF files and get every table back as rows you can export, plus one Excel file per PDF and one CSV per table. A table that runs over a page break comes back as one table, not three, and a header repeated on each page is dropped. You are charged per table delivered, never for a PDF that failed or had no tables.

### What you get

One dataset item per table, with the rows as objects keyed by the header. Real output from the default run (first 3 pages of a public California layoff-notice report; 3 pages, 1 table, 122 rows):

| Notice Date | Effective | Received | Company | City | No. Of | Layoff/Closure |
|---|---|---|---|---|---|---|
| 06/22/2015 | 03/25/2016 | 07/01/2015 | Maxim Integrated Product | San Jose | 150 | Closure Permanent |
| 06/30/2015 | 08/29/2015 | 07/01/2015 | McGraw-Hill Education | Monterey | 137 | Layoff Unknown at this time |
| 07/17/2015 | 09/18/2015 | 07/21/2015 | Boeing Company | Huntington Beach | 65 | Layoff Unknown at this time |

Each item also has `pdfUrl`, `table`, `tablesInPdf`, `pages`, `columns`, `rowCount`, `csvUrl`, `excelUrl` and `extractedAt`. The `excelUrl` file has one sheet per table with a frozen header row. The key-value store record `SUMMARY` lists PDFs that could not be read and PDFs where no tables were found.

### How to use

1. Add PDF links, one per line. The file must open in a browser without a login.
2. Optional: the pages to read (`1-3,7`; empty reads every page).
3. Pick the table detection: **lines** for tables drawn with ruled borders, **text** for tables laid out with spaces and no borders.
4. Run it, then open the **Tables** view or download the dataset as CSV, JSON or Excel. For one spreadsheet per PDF, use the `excelUrl` column.

Other options: join tables that continue on the next page (on by default), use the first row as the header (on by default), ignore tiny tables with fewer data rows than a minimum, a password for protected PDFs, and a maximum number of tables.

### Pricing

Pay per event: **$2.00 per 1,000 tables** (the dataset-item event) plus a $0.00005 Actor start. A 100-page report with one long table that continues across pages is one table. You set a maximum cost per run and the Actor stops cleanly at it.

### Limits (honest)

- Works on PDFs that contain real text. Scanned pages (pictures of paper) have no text to read and come back with no tables; there is no OCR.
- Table detection is a best effort. Ruled tables work best; borderless tables need the **text** setting and can merge or split columns when the spacing is uneven. Check the first run on your own layout.
- Cells that span several columns or rows are not split out. Text in a merged cell appears once, in the first column it covers.
- Dates that the PDF sets one character at a time (for example `0 3 / 2 5 / 2 0 16`) are closed up to `03/25/2016`. Other cell text is returned as the PDF has it, with extra whitespace collapsed.
- Joining across pages needs the same number of columns on both pages and the table to be the first one on the next page.
- Files up to 50 MB. Public links only.
- Check that you are allowed to use the PDFs you submit.

### FAQ

**My table came back empty or in pieces.** Try the other **Table detection** setting, lower **Minimum data rows**, or switch off **Join tables that continue on the next page** to see page by page.

**Something broke or you need a feature?** Open an issue on the Issues tab. I usually reply within a day.

# Actor input Schema

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

Direct links to PDF files, one per line. The file must be reachable without a login.

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

Optional. Which pages to read, for example 1-3,7. Empty reads every page.

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

lines finds tables drawn with ruled borders. text finds tables laid out with spaces and no borders.

## `mergeAcrossPages` (type: `boolean`):

A table that starts on the next page with the same number of columns is added to the table before it. A repeated header row is dropped.

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

Use the first row as column names. Turn off to get Column 1, Column 2 and so on.

## `minRows` (type: `integer`):

Ignore tiny tables with fewer data rows than this (layout boxes, page headers).

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

Optional. Only for password-protected files.

## `maxItems` (type: `integer`):

Stop after this many tables. You are charged per table delivered.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
  ],
  "pages": "1-3",
  "strategy": "lines",
  "mergeAcrossPages": true,
  "firstRowIsHeader": true,
  "minRows": 2,
  "maxItems": 100
}
```

# Actor output Schema

## `tables` (type: `string`):

No description

## `summary` (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 = {
    "pdfUrls": [
        "https://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
    ],
    "pages": "1-3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("adhistory/pdf-tables-to-excel").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://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"],
    "pages": "1-3",
}

# Run the Actor and wait for it to finish
run = client.actor("adhistory/pdf-tables-to-excel").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://raw.githubusercontent.com/jsvine/pdfplumber/stable/examples/pdfs/ca-warn-report.pdf"
  ],
  "pages": "1-3"
}' |
apify call adhistory/pdf-tables-to-excel --silent --output-dataset

```

## MCP server setup

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

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/mD8QRcJgOQEnyM4V5/builds/TRPzJlCiMm4q48NBt/openapi.json
