# PDF Table Extractor & PDF to JSON API: text, tables, metadata (`bosco_labs/pdf-to-data`) Actor

PDF table extractor and text parser: tables as JSON rows with a header guess, per-page markdown text in reading order, title, author and dates, from 1-20 public PDF URLs or a base64 file. Processed in memory, never stored. $0.0005 per page with text; scanned pages are flagged and free.

- **URL**: https://apify.com/bosco_labs/pdf-to-data.md
- **Developed by:** [Bosco Labs](https://apify.com/bosco_labs) (community)
- **Categories:** Developer tools, AI, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $0.50 / 1,000 pages

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 JSON API: text, tables and metadata from a PDF URL

Turn **any public PDF link (annual report, invoice, government notice, price list) into clean
JSON**: text per page in reading order (markdown headings and tables), tables as rows with a
header guess, and title, author and dates. Built for AI agents that meet a PDF mid-task and for
anyone who needs PDF data in a pipeline. **Pricing: $0.50 per 1,000 pages ($0.0005 per page
with text), no start fee.** Failed files and scanned pages without text are free.

Give 1 to 20 PDF URLs (or one file as base64). A 20-page PDF typically takes 3-10 seconds.
Files are processed in memory and never stored; their content is never logged.

### What you get

One row per PDF, written as soon as that PDF is done (so rows can arrive in a different order
than your input; `input_index` says which input it is). Real output for pages 1-2 of the SEC's
Form 10-K instructions (page text shortened here):

```json
{
  "schema_version": "1",
  "input_index": 0,
  "url": "https://www.sec.gov/files/form10-k.pdf",
  "final_url": "https://www.sec.gov/files/form10-k.pdf",
  "file_size_bytes": 549322,
  "page_count": 19,
  "pages_processed": 2,
  "pages_charged": 2,
  "title": "Form 10-K",
  "author": "U.S. Securities and Exchange Commission",
  "subject": "Annual Report Pursuant to Section 13 or 15(d) of the Securities Exchange Act of 1934",
  "creator": "Acrobat PDFMaker 24 for Word",
  "producer": "Adobe PDF Library 24.1.163",
  "creation_date": "2024-05-12T10:49:53-04:00",
  "modification_date": "2026-09-10T12:50:48-04:00",
  "pages": [
    {
      "page": 1,
      "text": "UNITED STATES\nSECURITIES AND EXCHANGE COMMISSION\nWashington, D.C. 20549\n\nOMB APPROVAL\nOMB Number: 3235-0063\n..."
    },
    {
      "page": 2,
      "text": "(2) Particular attention is directed to Regulation 12B which contains general requirements\n..."
    }
  ],
  "tables": [],
  "warnings": [],
  "error": null,
  "source_url": "https://www.sec.gov/files/form10-k.pdf",
  "retrieved_at": "2026-11-05T22:41:04+00:00"
}
```

A table, as found on page 14 of the IRS's Publication 15-T (wage bracket table, first two rows):

```json
{
  "page": 14,
  "header": ["At least", "than", null, null, "The Tentative Withholding Amount is:", null, null],
  "rows": [
    ["$0", "$155", "$0", "$0", "$0 $0", "$0", "$0"],
    ["$155", "$165", "$0", "$0", "$0 $0", "$0", "$1"]
  ],
  "n_cols": 7
}
```

| Field | Meaning |
|---|---|
| `input_index` | Position in your input, 0-based (`urls[input_index]`; `pdfBase64` comes after the URLs) |
| `url`, `final_url`, `source_url` | The link you gave, where it ended after redirects, and the source to cite |
| `file_size_bytes`, `page_count` | Size of the file and its total pages |
| `pages_processed`, `pages_charged` | Pages read in this run, and pages you paid for (pages with text) |
| `title`, `author`, `subject`, `creator`, `producer` | From the PDF's document info; `null` when not set |
| `creation_date`, `modification_date` | ISO 8601 with the file's UTC offset |
| `pages` | `{page, text}` per page read; `text` is `null` for pages without a text layer |
| `tables` | `{page, header, rows, n_cols}`; `header` is the first row when it looks like one, else `null`; empty cells are `null` |
| `warnings` | Scanned pages, pages left out by `maxPages`, page numbers past the end |
| `error` | Why a file failed (not charged); `null` on success |

### Input

```json
{ "urls": ["https://www.sec.gov/files/form10-k.pdf"], "pages": "1-5,10", "extract": ["text", "tables"] }
```

| Field | Meaning |
|---|---|
| `urls` | 1-20 public `http(s)` PDF links, up to 50 MB each |
| `pdfBase64` | Or the file itself, base64 (Apify limits run input to a few MB, so use URLs for big files) |
| `pages` | e.g. `"1-5,10"`; empty = all pages |
| `extract` | Any of `text`, `tables`, `metadata`; default all three |
| `maxPages` | Most pages read per PDF, default 50 (caps the cost per PDF) |
| `outputFormat` | `markdown` (default: `##` headings, `\| tables \|`) or `text` (plain, tab-separated table rows) |
| `timeoutSecs` | Most seconds of parsing per PDF, 5-600, default 120 |

### Use with AI agents (MCP)

Agents can call this Actor as a tool through the
[Apify MCP server](https://github.com/apify/apify-mcp-server). Add this server URL to your MCP
client (Claude, Cursor, VS Code, ...):

```text
https://mcp.apify.com?tools=bosco_labs/pdf-to-data
```

It loads this Actor as a tool, plus the tools that read its results (`get-actor-run`,
`get-dataset-items`). The hosted server signs you in with OAuth, or accepts your Apify token as
`Authorization: Bearer <APIFY_TOKEN>`. On the default server (`https://mcp.apify.com`), agents
can also find this Actor with `search-actors` and run it with `call-actor`.

Example prompt:

- *"Get the wage bracket table on page 14 of https://www.irs.gov/pub/irs-pdf/p15t.pdf as rows."*

The agent passes:

```json
{"urls": ["https://www.irs.gov/pub/irs-pdf/p15t.pdf"], "pages": "14", "extract": ["tables"]}
```

**Output for agents:** one JSON row per PDF with `schema_version`, `source_url` and a page
number on every page and table, so the agent can cite where a value came from. Errors come back
as a row with an `error` text, never as a crashed run.

**Cost:** $0.0005 per page with text, billed to the Apify account the MCP server is signed in
with. Ask for the pages you need (`pages`) to keep answers small and cheap.

### FAQ

**Scanned PDFs?** Pages that are only an image (scans, photos) have no text layer. They come
back with `text: null` and a warning, and are **not charged**. OCR is not supported.

**How good is table detection?** Tables are found from aligned text: three or more lines in a
row with two or more separate columns. Clean column layouts (price lists, statements, rate
tables) work well. Limits: cells that wrap over several lines come out as extra rows; columns
closer than about two characters merge into one cell; ruled tables are read from their text,
not their lines; a table next to running text can pick up that text as a column. The page text
always has everything, in reading order.

**Which PDFs are refused?** Links that are not `http(s)`, hosts that resolve to private,
local or cloud-metadata addresses (also after redirects), files over 50 MB, responses that are
not a PDF (e.g. a login page), password-protected and broken files. Each gives a row with an
`error` and costs nothing.

**What does a metadata-only run cost?** One page per PDF (`extract: ["metadata"]`).

**Are my files stored?** No. Each PDF is downloaded into memory, parsed and dropped. Only the
extracted data goes to your dataset; nothing from the document is logged.

**Size limits?** 50 MB per file, up to 500 pages per PDF per run (`maxPages`, default 50), and
about 8 MB of output per PDF. A warning tells you which `pages` to ask for next.

**Very complex or hostile PDFs?** Each PDF is parsed in its own process with a time limit
(`timeoutSecs`, default 120 s) and a memory limit. Pages are read until 3/4 of that time, then
the rest gets a warning. A PDF that is still stuck at the limit (for example one page that
inflates to tens of MB of drawing commands) is stopped and returns an `error` row ("PDF too
complex"), costs nothing, and the other PDFs in the run are delivered as usual.

**Speed?** Measured locally: 19 text pages in 2 s, 20 pages of the EU GDPR in 5 s, 50 pages of
IRS Publication 15 in 10-20 s (parsing time, download excluded).

# Actor input Schema

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

1 to 20 public http(s) links to PDF files, e.g. \["https://www.sec.gov/files/form10-k.pdf"]. Each PDF gives one output row. Files up to 50 MB; links to private or local addresses are refused. Empty = use pdfBase64 instead.

## `pdfBase64` (type: `string`):

Instead of (or besides) URLs: the PDF file itself, base64-encoded, optionally as a data: URI, e.g. "JVBERi0xLjQK...". Up to 50 MB decoded (Apify limits the whole input to a few MB, so use URLs for big files). Empty = none.

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

Which pages to read, 1-based, as ranges and single pages separated by commas, e.g. "1-5,10". Applies to every PDF; pages past the end are skipped with a warning. Empty = all pages (up to maxPages).

## `extract` (type: `array`):

Any of text, tables, metadata, e.g. \["tables"]. Default (empty) = all three. Metadata alone costs one page per PDF.

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

Most pages read per PDF, counted from the first selected page, e.g. 10. Default 50. You pay per page with text, so this caps the cost per PDF; a warning tells you how to request the rest.

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

How page text is written: "markdown" marks headings with ## and writes detected tables as markdown tables; "text" gives plain paragraphs and tab-separated table rows. Default markdown. The tables field is the same in both.

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

Most seconds spent parsing one PDF, e.g. 60. Default 120. Pages are read until 3/4 of this time (later pages get a warning and are not charged); a PDF still parsing at the limit is stopped and returns an error row, not charged. Empty = 120.

## Actor input object example

```json
{
  "urls": [
    "https://www.sec.gov/files/form10-k.pdf"
  ],
  "pages": "1-3",
  "extract": [
    "text",
    "tables",
    "metadata"
  ],
  "maxPages": 50,
  "outputFormat": "markdown",
  "timeoutSecs": 120
}
```

# 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.sec.gov/files/form10-k.pdf"
    ],
    "pages": "1-3"
};

// Run the Actor and wait for it to finish
const run = await client.actor("bosco_labs/pdf-to-data").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.sec.gov/files/form10-k.pdf"],
    "pages": "1-3",
}

# Run the Actor and wait for it to finish
run = client.actor("bosco_labs/pdf-to-data").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.sec.gov/files/form10-k.pdf"
  ],
  "pages": "1-3"
}' |
apify call bosco_labs/pdf-to-data --silent --output-dataset

```

## MCP server setup

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

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/vB1hqqP9QqDC8AEOd/builds/4iZ86nghHYEndOWj5/openapi.json
