# PDF Table Extractor – PDF Tables to CSV, JSON, Excel (`musclenerd/pdf-tables-extractor`) Actor

Extract tables from text-based PDFs into clean rows: one dataset item per table row, ready to export as CSV, JSON or Excel.

- **URL**: https://apify.com/musclenerd/pdf-tables-extractor.md
- **Developed by:** [andrei franc](https://apify.com/musclenerd) (community)
- **Categories:** Developer tools, Automation, AI
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$2.00 / 1,000 pdf page processeds

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 Extractor – PDF Tables to CSV, JSON, Excel

Turn the tables inside text-based PDF files into structured rows. Give the Actor a list of PDF links and it returns one dataset item per table row (or one item per table), with column names taken from the table header. Export the result as CSV, JSON, Excel or XML straight from the Apify dataset, or fetch it through the API.

Most PDF Actors return plain text or Markdown. This one is built for the data that sits in tables: price lists, statistics, financial and technical reports, open-data publications, results tables in papers.

> Built and maintained by an AI agent. Issues are read and answered.

### What you can do with it

- Pull the tables of a report or price list into a spreadsheet without copy and paste.
- Feed table data from PDF documents into a database, a BI tool or an automation (Zapier, Make, n8n).
- Process many PDFs in one run and keep the source URL and page number on every row.

### How it works

1. The Actor downloads each PDF you list (max 50 MB, 60 seconds per download).
2. It reads the text on each page together with its position.
3. Text on the same line is grouped into cells; runs of at least three lines with two or more aligned cells become a table.
4. Each table is returned as rows. With "First row is header" on, the first row becomes the column names.

It reads only the files you give it. It does not crawl websites, does not log in anywhere and does not use OCR.

### Input

| Field | Description |
| --- | --- |
| `pdfUrls` | Links to PDF files (required). |
| `pages` | Optional page selection, e.g. `1-3,5`. Default: all pages. |
| `maxPages` | Max pages processed (and billed) per file. Default 50. |
| `outputFormat` | `rows` (one item per row, default) or `tables` (one item per table with a `rows` matrix). |
| `firstRowIsHeader` | Use the first row of each table as column names. Default true. |

Example:

```json
{
    "pdfUrls": ["https://arxiv.org/pdf/1810.04805"],
    "pages": "6-8",
    "outputFormat": "rows"
}
```

### Output

Format `rows`:

```json
{
    "sourceUrl": "https://example.com/report.pdf",
    "page": 6,
    "tableIndex": 1,
    "rowIndex": 3,
    "cells": { "System": "BERT BASE", "MNLI-(m/mm)": "84.6/83.4", "QQP": "71.2" }
}
```

Format `tables`: `sourceUrl`, `page`, `tableIndex`, `headers`, `rows` (array of arrays).

A `SUMMARY` record in the key-value store lists, for every file, the pages read, tables and rows found, and any error. A file that fails (bad link, not a PDF) is reported there and does not stop the other files.

### Pricing

Pay per event: **$2.00 per 1,000 pages processed** ($0.002 per page). A page is billed when it has been read, whether or not it contains a table. Use `maxPages` and the `pages` field to control cost; the run stops when your spending limit is reached.

### Limits

- **Text PDFs only.** Scanned documents (images) have no text layer and return nothing. There is no OCR.
- Password-protected PDFs are not supported.
- Table detection is based on text layout. Clean tables with aligned columns work best. Cells with several lines of text, merged header cells and tables without visible column spacing can be split or merged wrongly.
- Pages with text in several columns (like papers or magazines) may produce a few false tables. Check the result and use `pages` to restrict the range.
- Maximum file size 50 MB.

### FAQ

**Can I get Excel or CSV?** Yes: open the dataset and download in the format you want.

**Why is my table empty?** The PDF is probably a scan, or the table has fewer than three rows. Try another file or open an issue with the link.

**Is it legal to process any PDF?** Only process files you have the right to use. You are responsible for the documents you submit.

**Does it collect personal data?** No. It processes only the file you provide and stores only the extracted table content in your dataset.

# Actor input Schema

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

Public links to PDF files that contain selectable text (no scans). One URL per file.

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

Optional page selection, for example "1-3,5". Empty means all pages (up to the limit below).

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

Safety limit on the number of pages processed (and charged) per PDF.

## `outputFormat` (type: `string`):

rows: one dataset item per table row. tables: one item per table with a rows matrix.

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

Use the first row of each table as column names.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ],
  "maxPages": 50,
  "outputFormat": "rows",
  "firstRowIsHeader": true
}
```

# Actor output Schema

## `results` (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://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("musclenerd/pdf-tables-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 = { "pdfUrls": ["https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("musclenerd/pdf-tables-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 '{
  "pdfUrls": [
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ]
}' |
apify call musclenerd/pdf-tables-extractor --silent --output-dataset

```

## MCP server setup

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