# PDF to Text API — Extract Text & Tables (`devone-studio/pdf-to-text-api`) Actor

Extract text, layout and tables from a PDF (URL or base64). Uses pdfplumber locally — no external call.

- **URL**: https://apify.com/devone-studio/pdf-to-text-api.md
- **Developed by:** [Ti Gg](https://apify.com/devone-studio) (community)
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 per 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/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 API — Extract Text, Layout, and Tables

Extract clean text, layout and table data from any PDF, given either as
a public URL or base64. Built on `pdfplumber` and runs entirely inside
the Apify worker — no external call to a third-party OCR service. Built
for **knowledge engineers**, **legal/financial analysts**, and **AI
agents** that ingest PDFs deterministically.

### Free trial

A free Apify account gives you about **5 USD of monthly credits**, more
than enough to extract several documents and validate the output schema
before paying.

### Use cases

1. **RAG ingestion** — drop a batch of PDF reports into the Actor and
   feed the returned `text` and `tables` straight into a vector store.
2. **Contract clause mining** — extract `text` per page, then run regex
   over clauses like `Termination`, `Liability`, `Governing Law`.
3. **Invoice line-item extraction** — `tables` array contains one entry
   per detected table; consume as CSV/JSON for downstream accounting
   pipelines.

### Input

```json
{
  "pdf_url": "https://arxiv.org/pdf/1706.03762.pdf"
}
```

| Field | Type | Default | Description |
|---|---|---|---|
| `pdf_url` | string | `""` | Public URL of the PDF (http/https). Mutually exclusive with `pdf_base64`. |
| `pdf_base64` | string | `""` | Base64-encoded PDF body. Use for private documents. |
| `include_tables` | boolean | `true` | Also extract tabular regions via pdfplumber's table finder. |

### Output (real run)

```json
[
  {
    "page_number": 1,
    "text": "Provided proper attribution is provided, Google hereby grants permission to reproduce the tables and figures in this paper solely for use in journalistic or scholarly works.\nAttention Is All You Need\nAshish Vaswani* Noam Shazeer* Niki Parmar* Jakob Uszkoreit*\nGoogle Brain  Google Brain  Google Research  Google Research",
    "tables_count": 0
  },
  {
    "page_number": 2,
    "text": "1 Introduction\nRecurrent neural networks, long short-term memory and gated recurrent neural networks in particular, have been firmly established as state-of-the-art approaches in sequence modeling and transduction problems.",
    "tables_count": 0
  }
]
```

| Field | Type | Description |
|---|---|---|
| `page_number` | integer | 1-based page index. |
| `text` | string | Extracted plain text for the page (whitespace normalised). |
| `tables_count` | integer | Number of tabular regions detected on the page. |

### Pricing (pay-per-event)

- **No subscription.** Free monthly credits apply first.
- **1 result = $0.001 USD** (about $1 per 1 000 results).
- Charged per item returned in the dataset; failed runs are not charged.

### Source, licence, limits

- Source: any PDF (URL or base64) you supply.
- Engine: [`pdfplumber`](https://github.com/jsvine/pdfplumber), MIT licence.
- Limits: pure-KNN Python implementation; runs locally inside the Actor
  memory. **No OCR** — image-only PDFs (e.g. scans) will produce empty
  text. Encrypted/password-protected PDFs are rejected.

### FAQ

**Why are some pages empty?**
Image-only PDFs (scans) need OCR, which is intentionally out of scope for
this Actor. Pre-process with an OCR engine or use a different Actor.

**Does it handle multi-column layouts?**
Yes — pdfplumber preserves column order by reading text clusters
left-to-right within `x_tolerance`.

**Can it preserve table structure?**
Tables are summarised as `tables_count`. The raw table cells are also
written when `include_tables=true`; downstream code reconstructs rows by
grouping cells with overlapping `y`-values.

**Is the upload size limited?**
Yes — Apify's per-run dataset cap is 5 MB per item. Very large PDFs
should be split into per-page runs.

**What about forms and checkboxes?**
pdfplumber does not parse AcroForm fields. If you need form data, use a
PDF form-aware library such as `pypdf`.

**How do I extract text from a private URL?**
Pass the file as base64 in `pdf_base64`. Anything that requires
authentication is unsupported by design.

### Other Actors from DevOne-Studio

- **[ted-tenders-api](https://apify.com/devone-studio/ted-tenders-api)** — TED (Tenders Electronic Daily) EU public procurement search.
- **[pubmed-articles-api](https://apify.com/devone-studio/pubmed-articles-api)** — NCBI PubMed biomedical literature with MeSH/DOI/year filters.
- **[federal-register-api](https://apify.com/devone-studio/federal-register-api)** — US federal agency rules, proposed rules, notices, presidential docs.
- **[sec-company-tickers](https://apify.com/devone-studio/sec-company-tickers)** — Resolve SEC CIK from ticker or company name (10,400+ issuers).
- **[sec-edgar-fulltext-search-api](https://apify.com/devone-studio/sec-edgar-fulltext-search-api)** — Full-text search across 35M+ SEC EDGAR filings and exhibits.
- **[sec-edgar-xbrl-frames-api](https://apify.com/devone-studio/sec-edgar-xbrl-frames-api)** — XBRL frames (Revenues, Assets, NetIncomeLoss) for ~6000 US issuers.
- **[cfpb-consumer-complaints-api](https://apify.com/devone-studio/cfpb-consumer-complaints-api)** — 18M+ US CFPB consumer complaints since 2011.
- **[nhtsa-safety-ratings-api](https://apify.com/devone-studio/nhtsa-safety-ratings-api)** — NHTSA NCAP 5-star vehicle safety ratings.
- **[openfda-udi-api](https://apify.com/devone-studio/openfda-udi-api)** — FDA Unique Device Identifier database by device/manufacturer.
- **[eia-state-electricity-api](https://apify.com/devone-studio/eia-state-electricity-api)** — US state-level electricity generation and consumption, 1990-2025.

### Changelog

- **2026-10-12** — SEO metadata (seoTitle, seoDescription); README rewritten with real output sample, FAQ, cross-links.
- **2026-10-07** — Pricing switched to Apify pay-per-event (`$0.001` per dataset item).
- **2026-09-30** — Initial public release on the Apify Store.

# Actor input Schema

## `pdf_url` (type: `string`):

Public HTTPS URL of a PDF.

## `max_pages` (type: `integer`):

Stop after this many pages.

## Actor input object example

```json
{
  "pdf_url": "",
  "max_pages": 50
}
```

# Actor output Schema

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

All results of the run, as JSON from the default dataset.

# 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("devone-studio/pdf-to-text-api").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("devone-studio/pdf-to-text-api").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 devone-studio/pdf-to-text-api --silent --output-dataset

```

## MCP server setup

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

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/8qZ1lFPatKaisq4pF/builds/g249O2BcxdjcmHEYH/openapi.json
