# PDF Table Extractor & PDF to Text (CSV, JSON) (`k09/pdf-text-tables`) Actor

Extract tables from PDF to CSV and get clean text from every page. For invoices, bank statements and reports. Upload a file or paste links, choose pages. Pay per page; failed files are free.

- **URL**: https://apify.com/k09/pdf-text-tables.md
- **Developed by:** [K09 Tools](https://apify.com/k09) (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 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 to Text

**Extract tables from PDF to CSV** and get clean text from every page. A simple PDF parser for invoices, bank statements, financial reports, price lists and government documents. Convert PDF to CSV, Excel-ready tables or JSON without copy-pasting. Upload a file or paste links, pick the pages you need, and get:

- **One row per page** with the page's text in reading order.
- **Every table detected on the page** as rows and columns, plus a **CSV file per table** you can open in Excel or Google Sheets.

Good for invoices, statements, reports, price lists, government and financial documents, and preparing PDFs for AI/LLM pipelines.

> Just one short PDF? Try the free browser version: **[K09 PDF to CSV](https://k09zz.github.io/k09-tools/pdf-to-csv/)** (up to 20 pages, no upload). This Actor is for batches, long files, links, the API and automation.

### How it works

1. Upload a PDF, or paste one or more links.
2. Optional: choose pages (for example `1-3,5,10-`) and turn table extraction on or off.
3. Run it. Leave the input empty to try it free on a built-in sample.

### Output

Each dataset row is one page:

```json
{
  "fileName": "report.pdf",
  "page": 1,
  "pageCount": 12,
  "text": "Quarterly Sales Report\nThis report summarizes...",
  "tableCount": 1,
  "tables": [
    {
      "rows": [["Region", "Q1 sales", "Q2 sales", "Change"],
               ["North America", "1,204,500", "1,318,250", "+9.4%"]],
      "rowCount": 5,
      "columnCount": 4,
      "csvUrl": "https://api.apify.com/v2/key-value-stores/.../records/file1-page1-table1.csv"
    }
  ]
}
```

The dataset has two views: **Pages** (text) and **Tables** (one row per table with a CSV download link). Export either view as CSV, Excel or JSON.

### Features

- Text in reading order. Two-column article layouts are read column by column instead of mixed line by line.
- Table cells are separated by tabs in the text, so the layout survives copy and paste.
- Table detection works on whitespace-aligned tables, the most common kind in generated PDFs, with right-aligned numbers and multi-word cells.
- Password-protected PDFs are supported if you provide the password.
- Bad links, non-PDF files and damaged pages are reported in the output and **not charged**.

### Limitations

- **No OCR.** Scanned PDFs (photos of paper) contain no text layer, so they return empty text.
- Tables whose cells wrap over several lines, or that have merged header cells, may come out with extra rows or shifted cells. Check the CSV for complex layouts.
- Maximum file size: 100 MB.

### Pricing

Pay per event:

- **Page processed**: charged for each page in your chosen range.
- **Table extracted**: charged for each table found (turn off *Extract tables* for text-only runs).

Failed files and pages are free. If you set a maximum cost for the run, the Actor stops cleanly and keeps everything processed so far.

### Privacy

Your files are processed only inside your own run. Output is saved to your own run's storage and nowhere else.

### Use it from code or AI agents

Every run can be started from the API, and results come back as JSON, CSV or Excel. Replace `YOUR_APIFY_TOKEN` with the token from **Apify Console → Settings → API & Integrations**.

**cURL** (runs the Actor and returns the results in one call):

```bash
curl -X POST "https://api.apify.com/v2/acts/k09~pdf-text-tables/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"pdfUrls":["https://example.com/report.pdf"],"pages":"1-5","extractTables":true}'
```

**Python** (`pip install apify-client`):

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("k09/pdf-text-tables").call(run_input={
    "pdfUrls": [
        "https://example.com/report.pdf"
    ],
    "pages": "1-5",
    "extractTables": True
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item)
```

**JavaScript / Node.js** (`npm install apify-client`):

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

const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const run = await client.actor('k09/pdf-text-tables').call({
  "pdfUrls": [
    "https://example.com/report.pdf"
  ],
  "pages": "1-5",
  "extractTables": true
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
```

**No-code and AI agents:** the Actor works with Apify's Zapier, Make and n8n integrations, can run on a schedule from the Console, and can be used as a tool by AI agents through Apify's MCP server (see Apify's MCP documentation).

# Actor input Schema

## `pdfFile` (type: `string`):

Upload a PDF file or paste a link to one.

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

Links to PDF files, one per line. Leave everything empty to try the Actor on a built-in sample (free).

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

Which pages to process, e.g. "1-3,5,10-". Empty means all pages. You only pay for pages processed.

## `extractTables` (type: `boolean`):

Detect tables and save each one as CSV. Turn off for text only (tables are charged separately).

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

Only needed for password-protected PDFs.

## Actor input object example

```json
{
  "extractTables": true
}
```

# Actor output Schema

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

No description

## `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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("k09/pdf-text-tables").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("k09/pdf-text-tables").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 '{}' |
apify call k09/pdf-text-tables --silent --output-dataset

```

## MCP server setup

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

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/ylRWJgKuGc6aUzxTK/builds/CyWIlfnu7vJ33xdbi/openapi.json
