# PDF Text Extractor: PDF to Text, Tables & Metadata API (`saadhazz/pdf-text-extractor`) Actor

Convert PDF URLs to clean text, page by page, with tables as Markdown and document metadata (title, author, dates, page count). Built for RAG, LLM and search pipelines. Scanned pages are flagged and never charged. $2 per 1,000 PDFs + $0.20 per 1,000 pages.

- **URL**: https://apify.com/saadhazz/pdf-text-extractor.md
- **Developed by:** [saad hazz](https://apify.com/saadhazz) (community)
- **Categories:** AI, Developer tools
- **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 Text Extractor: Convert PDF to Text, Tables & Metadata (API for RAG & LLMs)

**Send PDF URLs, get back clean text page by page,** plus tables as Markdown and document metadata (title, author, creation date, page count, PDF version). It's built for **RAG pipelines, LLM ingestion, search indexing and document automation**. You pay only for pages that actually contain text: **scanned or blank pages are flagged and never charged.**

### Features

- **Accurate text extraction.** Spacing adapts to font size, so tightly kerned PDFs such as LaTeX papers come out as readable words instead of `wordsruntogether`.
- **Per-page output.** Each page includes its text, character and word counts and a `needsOcr` flag, which makes chunking for embeddings straightforward.
- **Tables as Markdown** (optional). Ruled tables are detected per page and returned as GitHub-flavored Markdown that LLMs read well.
- **Metadata.** Title, author, subject, keywords, creator, producer, creation and modification dates (ISO 8601), PDF version, encryption status, page count, file size and SHA-256 (useful for deduplication).
- **Handles real-world inputs.** Redirects are followed, files over your size cap are skipped, non-PDF responses are caught by checking the `%PDF` header, and password-protected PDFs are supported if you supply the password.
- **Very large documents.** If the text would exceed Apify's dataset item limit, the full text goes to the key-value store and the row tells you the key (`fullTextKey`).
- **Fair billing.** Failed downloads, 404s, non-PDFs and corrupt files are free and listed in the `FAILED_DOCUMENTS` record.

### Input

| Field | Description |
|---|---|
| `urls` | Direct PDF links. You can also upload a text file of URLs. |
| `includePages` | Adds a `pages` array with per-page text (default on). The full text is always in `text`. |
| `extractTables` | Returns detected tables as Markdown (default off). |
| `maxPagesPerPdf` | Only processes the first N pages of each PDF (default 1000). |
| `maxFileSizeMb` | Skips files larger than this (default 50 MB). |
| `password` | Password for encrypted PDFs. Optional. |
| `maxConcurrency` | Maximum parallel downloads. |

### Output example

```json
{
  "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
  "fileName": "fw9.pdf",
  "fileSizeBytes": 140815,
  "title": "Form W-9 (Rev. March 2024)",
  "creationDate": "2024-03-06T08:18:13Z",
  "pdfVersion": "1.7",
  "pageCount": 6,
  "pagesWithText": 6,
  "pagesNeedingOcr": 0,
  "wordCount": 6279,
  "text": "Form W-9\nRequest for Taxpayer\n(Rev. March 2024) Identification Number and Certification ...",
  "pages": [
    { "pageNumber": 1, "text": "...", "charCount": 5659, "wordCount": 933, "needsOcr": false, "tables": ["| 3a Check the appropriate box ... |\n| --- |\n..."] }
  ],
  "tablesFound": 4,
  "extractedAt": "2026-10-06T17:45:00Z"
}
```

### Pricing (pay per event)

| Event | Price |
|---|---|
| PDF processed (downloaded, parsed, saved) | **$0.002** ($2 per 1,000 PDFs) |
| Page with text | **$0.0002** ($0.20 per 1,000 pages) |
| Scanned/blank page, failed download, non-PDF | **free** |

For example, 1,000 ten-page reports cost about $4. Set *Max total charge* in the run options and the Actor will respect it exactly: if the budget runs out partway through a document, it stops at the last page you can afford and tells you so in `note`.

### Scanned PDFs (OCR)

This version extracts the PDF's text layer, which covers almost all digitally created PDFs (reports, invoices, filings, papers, forms). Image-only pages are marked `needsOcr: true` and are not billed, so you can send just those to an OCR service. Built-in OCR is on the roadmap.

### Use with LangChain, LlamaIndex & vector databases

Use the `pages` array as pre-split chunks with page numbers for citations, or split `text` yourself. You can call the Actor from Python or JavaScript with the Apify client, from Make, Zapier or n8n, or through the Apify MCP server from AI agents.

### Legal

The Actor downloads only the URLs you provide, with no crawling. You are responsible for having the right to process the documents you submit (for example your own files, public-domain government forms, or openly licensed papers). No data is kept beyond your run's storage.

### FAQ

**Can it read password-protected PDFs?** Yes, if you supply the password. Without it, the file is reported in `FAILED_DOCUMENTS` and you are not charged.

**Does it keep the layout?** Text follows reading order, line by line. Tables come out as Markdown when `extractTables` is on.

**Can I send files from Google Drive or Dropbox?** Yes, as long as the link is a direct download link that returns the PDF itself.

### More data APIs from the same developer

- [Job Search API: Career Site Jobs](https://apify.com/saadhazz/career-site-job-search): search 400k+ jobs from 13,000+ company career sites (Greenhouse, Lever, Ashby, Workable…) by title, country and remote, with new-job alerts. $2 / 1,000 jobs.
- [ATS Jobs API](https://apify.com/saadhazz/ats-jobs-api): every open job from a list of companies on Greenhouse, Lever, Ashby, SmartRecruiters or Recruitee, in one schema. $1 / 1,000 jobs.
- [Remote Jobs API](https://apify.com/saadhazz/remote-jobs-aggregator): remote and work-from-home jobs from Remote OK, Himalayas, Jobicy and Arbeitnow, deduplicated. $1 / 1,000 jobs.
- [Bulk WHOIS & RDAP Lookup](https://apify.com/saadhazz/domain-whois-rdap): domain expiry dates, registrar, age, status, nameservers, MX/SPF/DMARC for thousands of domains. $1 / 1,000 domains.
- [Sitemap URL Extractor](https://apify.com/saadhazz/sitemap-url-extractor): every URL a website lists in its XML sitemaps, with lastmod, hreflang and optional HTTP status. $0.40 / 1,000 URLs.
- [SEC EDGAR Filings Monitor](https://apify.com/saadhazz/sec-filings-monitor): new 8-K, 10-Q, 10-K and Form 4 filings for a list of tickers from the official SEC API.

Found a bug or need a field? Open an issue on the Issues tab; Issues are checked daily.

# Actor input Schema

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

Direct links to PDF files (http/https). Redirects are followed. Duplicate URLs are removed.

## `includePages` (type: `boolean`):

Adds a `pages` array with text, character/word counts and the needsOcr flag for every page. The full document text is always in `text`.

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

Detects ruled tables and returns them as Markdown per page (slower on long documents).

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

Only the first N pages of each PDF are processed (and billed).

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

PDFs larger than this are skipped (free) and listed in FAILED_DOCUMENTS.

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

Optional: password for encrypted PDFs (applied to all URLs).

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

How many lookups/downloads run in parallel.

## Actor input object example

```json
{
  "urls": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ],
  "includePages": true,
  "extractTables": false,
  "maxPagesPerPdf": 1000,
  "maxFileSizeMb": 50,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

One PDF per item: metadata, full text and optional per-page text and Markdown tables.

## `failedDocuments` (type: `string`):

URLs that could not be downloaded or parsed (not charged).

## `runStats` (type: `string`):

Counters for results, HTTP outcomes and errors in this run.

## `allRecords` (type: `string`):

Every auxiliary record written by the run (reports, invalid/failed inputs, large text files).

# 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": [
        {
            "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("saadhazz/pdf-text-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": [{ "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf" }] }

# Run the Actor and wait for it to finish
run = client.actor("saadhazz/pdf-text-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": [
    {
      "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
    }
  ]
}' |
apify call saadhazz/pdf-text-extractor --silent --output-dataset

```

## MCP server setup

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