# PDF to Text, Markdown & Tables Extractor (`pennapixel/pdf-tables-extractor`) Actor

Turn PDF URLs into clean text, LLM-ready Markdown and tables as rows (JSON, CSV, Excel). Page ranges, per-page output, safe metadata. Fast, no browser, no proxy. Pay per PDF and per page.

- **URL**: https://apify.com/pennapixel/pdf-tables-extractor.md
- **Developed by:** [Penna & Pixel](https://apify.com/pennapixel) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** 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 pdf 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 to Text, Markdown & Tables Extractor

Turn **PDF links into clean text, LLM-ready Markdown and real tables** (rows and cells you can open in Excel or Google Sheets). No browser, no proxy, no OCR bill: it reads the text layer of digital PDFs directly, so it is fast and cheap.

### What you get for each PDF

- **Full text** in reading order, and **Markdown** with page markers (`<!-- page 3 -->`) ready for RAG and LLM prompts
- **Tables as rows of cells** (`tables[].rows`), also embedded as Markdown tables inside the Markdown output
- **Page count, word count, character count**, table count
- **Document metadata**: title, subject, keywords, creator tool, producer, creation and modification dates
- A **scanned-PDF warning** (`isScanned`, `scannedPages`) when pages contain only images, so you know when OCR would be needed
- Optional **one row per page** (`outputMode: "page"`): ideal for chunking long documents

### Use cases

- Feed annual reports, manuals, papers and policies to an LLM or a vector database
- Pull tables out of statistical reports, price lists, invoices and spec sheets into a spreadsheet
- Index a document library for search
- Monitor public PDFs (tenders, regulations, price lists) together with a scheduler

### Input

```json
{
  "urls": [
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf",
    "https://www.census.gov/retail/marts/www/marts_current.pdf"
  ],
  "outputMode": "document",
  "extractTables": true,
  "pageRange": "1-5"
}
```

| Field | What it does |
| --- | --- |
| `urls` | Public PDF links (redirects are followed) |
| `outputMode` | `document` (one row per PDF) or `page` (one row per page) |
| `extractTables` | Detect tables and return them as rows (default on) |
| `keepLayout` | Keep columns aligned with spaces: best for tables **without ruling lines** |
| `pageRange` | `1-5`, `1, 3, 10-12`, `20-` … empty = all pages |
| `includePageTexts` | In document mode, also add the text of each page |
| `maxPagesPerPdf`, `maxFileSizeMb`, `parseTimeoutSecs` | Safety caps (pages over the cap are not read and not charged) |

### Output (a real run on the W3C example table, text field left out)

```json
{
  "url": "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf",
  "fileName": "table.pdf",
  "status": "ok",
  "pageCount": 1,
  "pagesProcessed": 1,
  "creatorTool": "Acrobat PDFMaker 9.0 for Word",
  "producer": "Adobe PDF Library 9.0",
  "createdAt": "2011-01-23T14:42:32-05:00",
  "isScanned": false,
  "wordCount": 65,
  "tableCount": 1,
  "markdown": "<!-- page 1 -->\n\nExample table\nThis is an example of a data table.\n\n| Disability Category | Participants | Ballots Completed | Ballots Incomplete/ Terminated | Results Accuracy | Time to complete |\n| --- | --- | --- | --- | --- | --- |\n| Blind | 5 | 1 | 4 | 34.5%, n=1 | 1199 sec, n=1 |\n...",
  "tables": [{
    "page": 1, "index": 1, "rowCount": 5, "columnCount": 6,
    "rows": [
      ["Disability Category", "Participants", "Ballots Completed", "Ballots Incomplete/ Terminated", "Results Accuracy", "Time to complete"],
      ["Blind", "5", "1", "4", "34.5%, n=1", "1199 sec, n=1"],
      ["Low Vision", "5", "2", "3", "98.3% n=2 (97.7%, n=3)", "1716 sec, n=3 (1934 sec, n=2)"]
    ]
  }]
}
```

Merged header cells are folded back into one header row, so the table keeps its real columns. In the dataset, the **Overview** view shows one line per PDF and the **Text** view the Markdown.

Links that fail (not a PDF, 404, too large, password-protected) appear as rows with `status: "failed"` and a readable `error`, and **are not charged**.

### Pricing

Pay only for what is read:

- **$0.002 per PDF** processed successfully
- **$0.0001 per page** read
- **$0.003 per run** start

One 10-page PDF in a run costs **$0.006**; 1,000 one-page invoices in one run cost about **$2.10**. Failed links, skipped pages and pages over your caps are free. You can always set a maximum cost per run in the run options.

### Good to know

- **No OCR.** Scanned PDFs (images only) return little or no text; they are flagged with `isScanned` so you can send just those to an OCR tool.
- **Tables:** tables with ruling lines are detected best. For tables without lines, turn on `keepLayout` and you get the text with columns aligned, which LLMs read well.
- **Polite by design:** the actor respects each site's robots.txt, waits between requests to the same site and refuses private or internal network addresses.
- **Privacy:** the PDF *Author* field is deliberately not returned. Only extract documents you have the right to process.
- Password-protected PDFs are reported as failed.

### Support

Found a PDF that comes out wrong? Open an issue on the actor page with the link and what you expected: fixes are usually quick.

# Actor input Schema

## `urls` (type: `array`):

Public links to PDF files (http or https). One PDF per line. Links that redirect to a PDF are fine.

## `outputMode` (type: `string`):

Document: one dataset row per PDF with the full text, Markdown and all tables. Page: one row per page (handy for RAG chunking and long documents).

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

Detect tables and return them as rows of cells, and as Markdown tables inside the Markdown output.

## `keepLayout` (type: `boolean`):

Keep columns aligned with spaces, as they look on the page. Useful for tables without ruling lines (statistical reports, statements) and for feeding an LLM. Off = plain reading-order text.

## `pageRange` (type: `string`):

Optional. Examples: "1-5", "1, 3, 10-12", "20-" (from page 20 to the end). Empty = all pages.

## `includePageTexts` (type: `boolean`):

In document mode, also add a 'pages' list with the text of each page.

## `maxPagesPerPdf` (type: `integer`):

Safety cap: pages after this number are skipped (and not charged).

## `maxFileSizeMb` (type: `integer`):

Larger files are skipped with an error row (not charged).

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

How many PDFs are downloaded and read at the same time. Requests to the same website are always spaced out politely.

## `parseTimeoutSecs` (type: `integer`):

A PDF that takes longer than this to read is reported as failed (not charged).

## Actor input object example

```json
{
  "urls": [
    "https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"
  ],
  "outputMode": "document",
  "extractTables": true,
  "keepLayout": false,
  "includePageTexts": false,
  "maxPagesPerPdf": 300,
  "maxFileSizeMb": 50,
  "maxConcurrency": 3,
  "parseTimeoutSecs": 180
}
```

# 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 = {
    "urls": [
        "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("pennapixel/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 = { "urls": ["https://www.w3.org/WAI/WCAG21/working-examples/pdf-table/table.pdf"] }

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,pennapixel/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/3AsXGmlF0KamwPyLE/builds/V0KlxGKTTcjZyp5Tn/openapi.json
