# PDF Text Extractor — Structured Tables, Markdown & Metadata (`nuhemugames/pdf-text-table-extractor`) Actor

Extract text from PDF URLs at scale: full text, per-page text, real structured tables (rows and columns as JSON, not text lines), document metadata and clean Markdown for LLM/RAG. The table extraction generic PDF text extractors don't have. No credentials needed.

- **URL**: https://apify.com/nuhemugames/pdf-text-table-extractor.md
- **Developed by:** [kuon](https://apify.com/nuhemugames) (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

from $4.00 / 1,000 results

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/platform/actors/running/actors-in-store#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## PDF Text Extractor — Structured Tables, Markdown & Metadata

Extract text from PDF URLs at scale — and get the one thing generic PDF text
extractors don't give you: **tables as real structured data (rows and columns
as JSON), not flattened text lines**. Every PDF also yields full text,
per-page text, document metadata, and a clean Markdown rendition with
reconstructed headings and bullet lists. No credentials or API keys needed.

### Why this extractor

- **PDF table extraction to JSON**: `[["Fruit","Qty"],["Apple","120"]]` — ready
  for spreadsheets, databases or analysis. Most PDF text extractors return
  tables as jumbled text lines; this one returns rows and columns.
- **PDF to Markdown for LLM / RAG pipelines**: headings inferred from font
  sizes, bullet lists preserved, tables as Markdown pipe tables — and table
  text is never duplicated as prose, so your chunks stay clean.
- **PDF to text in bulk**: pass a list of URLs; failures (404s, broken or
  password-protected files) become failed items, never a crashed run.

### What it does

Give it a list of PDF URLs. For each PDF you get one dataset item with:

- `fullText` — the whole document as plain text
- `pages[]` — per-page text with word and character counts
- `tables[]` — every detected table as an array of rows (`[["Fruit","Qty"],["Apple","120"],…]`), with the page number it was found on
- `markdown` — a Markdown version of the document: headings inferred from font sizes, bullet lists, and tables as Markdown pipe tables (table text is not duplicated as prose)
- `metadata` — title, author, subject, keywords, creator, producer, creation/modification dates (ISO 8601)
- `stats` — word count, character count, table count

Failed downloads or broken files produce an item with `status: "failed"` and a
clear `error` message instead of crashing the run, so batch jobs always finish.

### Input

| Field | Type | Default | Description |
|---|---|---|---|
| `pdfUrls` | array | — | Direct URLs to PDF files (redirects followed) |
| `includePageTexts` | boolean | `true` | Include the per-page `pages` array |
| `includeTables` | boolean | `true` | Detect and extract structured tables |
| `includeMarkdown` | boolean | `true` | Include the Markdown rendition |
| `maxPagesPerPdf` | integer | `0` (all) | Process only the first N pages |
| `timeoutSecs` | integer | `60` | Download timeout per file |
| `maxFileSizeMb` | integer | `50` | Larger files are skipped with a failed item |

### Example output (abridged)

```json
{
    "url": "https://example.com/report.pdf",
    "status": "success",
    "metadata": {"title": "Quarterly Fruit Report", "author": "AtoA Workshop"},
    "numPages": 2,
    "fullText": "Quarterly Fruit Report\nThis report summarizes...",
    "pages": [{"page": 1, "text": "...", "words": 32, "chars": 195}],
    "tables": [{"page": 2, "tableIndex": 0, "rows": [["Fruit", "Quantity", "Price"], ["Apple", "120", "1.50"]]}],
    "markdown": "## Quarterly Fruit Report\n...\n| Fruit | Quantity | Price |\n|---|---|---|\n| Apple | 120 | 1.50 |",
    "stats": {"words": 47, "chars": 289, "tables": 1}
}
```

### Typical uses

- Convert reports, invoices and papers to analyzable data (PDF table extraction)
- Feed LLM / RAG pipelines with clean Markdown instead of raw PDF text
- Index PDF archives: full text + metadata (title, author, dates) per document
- Batch-convert PDF URLs from a crawl or sitemap into text datasets

### Limitations

- No OCR: scanned image-only PDFs return empty text (selectable text required)
- Password-protected PDFs are reported as failed items
- Table detection works best on tables with ruled borders; borderless layouts may be missed
- The Markdown rendition is heuristic — heavily designed layouts may come out flatter

### Development (local)

```bash
cd actors/pdf-text-table-extractor
uv venv .venv && .venv/bin/python -m ensurepip 2>/dev/null; uv pip install -p .venv/bin/python -r requirements.txt
uv pip install -p .venv/bin/python fpdf2          # dev-only: fixture generator

.venv/bin/python tests/run_local_test.py           # end-to-end test (apify run equivalent), exit 0 = ALL PASS
../../node_modules/.bin/apify run                  # real apify CLI local run (input: storage/key_value_stores/default/INPUT.json)
```

Test fixture is `tests/fixtures/sample.pdf` (regenerate with `tests/make_fixture.py`);
expected results live in `tests/expected_output.json`. Publishing → `../../docs/publishing.md`.

# Actor input Schema

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

Direct URLs of the PDF files to process (one per line). Redirects are followed. Pages embedding a PDF viewer will not work — link to the .pdf file itself.

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

Add a `pages` array with the text, word count and character count of each page.

## `includeTables` (type: `boolean`):

Detect tables and return them as structured rows and columns (array of string arrays), not flattened text.

## `includeMarkdown` (type: `boolean`):

Reconstruct a Markdown version of the document: headings from font sizes, bullet lists, and tables as Markdown pipe tables. Heuristic — complex layouts may come out flatter.

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

Process only the first N pages of each PDF. 0 means all pages.

## `timeoutSecs` (type: `integer`):

Timeout for downloading each PDF.

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

PDFs larger than this are skipped with a failed item.

## Actor input object example

```json
{
  "pdfUrls": [
    "https://arxiv.org/pdf/1706.03762"
  ],
  "includePageTexts": true,
  "includeTables": true,
  "includeMarkdown": true,
  "maxPagesPerPdf": 0,
  "timeoutSecs": 60,
  "maxFileSizeMb": 50
}
```

# Actor output Schema

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

All dataset items (one per PDF): fullText, pages, tables, markdown, metadata, stats.

# 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://arxiv.org/pdf/1706.03762"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("nuhemugames/pdf-text-table-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://arxiv.org/pdf/1706.03762"] }

# Run the Actor and wait for it to finish
run = client.actor("nuhemugames/pdf-text-table-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://arxiv.org/pdf/1706.03762"
  ]
}' |
apify call nuhemugames/pdf-text-table-extractor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,nuhemugames/pdf-text-table-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/W567LpeK61wg1cDze/builds/zkRymn5W435xHBwbg/openapi.json
