# PDF to Text, Markdown and Tables (with OCR) (`gigsmith/pdf-to-text-markdown-tables`) Actor

Convert PDFs to clean text, Markdown and tables for RAG and AI pipelines. Scanned pages are OCR'd automatically. $0.003 per PDF + $0.004 per OCR page.

- **URL**: https://apify.com/gigsmith/pdf-to-text-markdown-tables.md
- **Developed by:** [Gigsmith](https://apify.com/gigsmith) (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 $3.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 and Tables (with OCR for scanned pages)

**PDF to Text, Markdown and Tables** converts PDF files into clean plain text, LLM-ready Markdown and structured tables. Pages with no text layer, such as scans, faxes and photographed documents, are detected and **read with OCR automatically**. Paste PDF links or upload files and get one result row per PDF.

**Pricing: $0.003 per PDF plus $0.004 per scanned page that needs OCR. Text-layer pages cost nothing extra.**

### What does this PDF extractor do?

- 📄 **PDF to text**: the PDF's own text layer in reading order, with pages separated by a form feed (`\f`), just like `pdftotext`
- 📝 **PDF to Markdown**: text and tables in page order, with a `<!-- page N -->` marker per page, ready for RAG chunking, embeddings and LLM prompts
- 📊 **Table extraction**: ruled tables come back as **rows (arrays of cells)** and as **Markdown tables**, and their text is kept out of the body text so nothing is duplicated
- 🔎 **OCR fallback for scanned pages** (Tesseract 5, 20 languages): only pages with no usable text are OCR'd, so mixed PDFs cost the least
- 🗂️ **Per-page output**: text, OCR flag, OCR confidence, table and image counts for every page
- 🔐 **Password-protected PDFs**: supply the password as an encrypted secret input
- 🧾 **Metadata**: title, author, creator, producer and dates
- 💸 **Fair billing**: broken links, non-PDF files and corrupt PDFs are reported and never charged

### Who is it for?

- **AI and RAG builders** who need clean Markdown from document collections
- **Analysts, legal and finance teams** extracting text and tables from reports, contracts, statements and filings
- **Automation builders** on Make, Zapier or n8n who need PDF text in a workflow
- **Archivists** digitising scanned paperwork

### How to convert PDF to text and Markdown

1. Click **Try for free**.
2. Paste public PDF links into **PDF URLs**, or upload files under **Or upload PDFs**.
3. Leave **OCR for scanned pages** on **Auto**. Set **OCR languages** if your scans aren't in English.
4. Click **Start**. Download the results as JSON, CSV or Excel, or read them with the Apify API. Use the **Tables** and **Pages** views in the Output tab for one row per table or page.

#### Input example

```json
{
  "fileUrls": ["https://example.com/reports/q3-2026.pdf", "https://example.com/scans/contract.pdf"],
  "ocrMode": "auto",
  "ocrLanguages": ["eng"],
  "extractTables": true,
  "includePages": true
}
```

| Field | What it does |
|---|---|
| `fileUrls` / `uploadedFiles` | PDF links or uploaded PDFs |
| `ocrMode` | `auto` (scanned pages only, default), `always` (OCR every page), `never` (text layer only, no OCR charges) |
| `ocrLanguages` | Tesseract codes such as `eng`, `deu`, `fra`, `spa`, `heb`, `ara`, `chi_sim`, `jpn` |
| `extractTables` | Detect ruled tables (default `true`) |
| `includePages` | Add per-page results (default `true`) |
| `pdfPassword` | Secret. Password for protected PDFs |
| `maxPages` | Pages per PDF to process (default 500) |
| `ocrMinChars` | In auto mode, an image-covered page with fewer characters than this is OCR'd (default 25). Pages with no text at all are always OCR'd. |
| `ocrDpi` | OCR render resolution, 150–400 (default 300) |

#### Output example

This is real output from a test run on a one-page sales report:

```json
{
  "fileName": "sales_report_tables.pdf",
  "status": "ok",
  "pageCount": 1,
  "ocrPageCount": 0,
  "tableCount": 2,
  "charCount": 276,
  "text": "Quarterly Sales Report - Q3 2026\nThis report summarises sales by region for the third quarter. ...",
  "markdown": "<!-- page 1 -->\n\nQuarterly Sales Report - Q3 2026\n...\n\n| Region | Q2 revenue | Q3 revenue | Change |\n|---|---|---|---|\n| North America | $410,200 | $438,900 | +7.0% |\n| EMEA | $265,000 | $318,400 | +20.2% |\n...",
  "tables": [
    {
      "page": 1, "index": 1, "rowCount": 5, "columnCount": 4,
      "rows": [["Region", "Q2 revenue", "Q3 revenue", "Change"], ["North America", "$410,200", "$438,900", "+7.0%"]],
      "markdown": "| Region | Q2 revenue | Q3 revenue | Change |\n|---|---|---|---|\n..."
    }
  ],
  "pages": [{ "page": 1, "text": "...", "ocr": false, "ocrConfidence": null, "tableCount": 2, "imageCount": 0 }],
  "processingSeconds": 0.05
}
```

On a mixed PDF (one digital page followed by two scanned pages), `pages[].ocr` comes back `[false, true, true]` and `ocrPageCount` is `2`. You're charged $0.003 + 2 × $0.004 = $0.011.

### How much does PDF extraction cost?

Pay-per-event pricing means you pay only for what was actually processed.

| Event | Price | When it's charged |
|---|---|---|
| `pdf-processed` | **$0.003** | Once per PDF that opened and converted successfully |
| `ocr-page` | **$0.004** | Once per page read with OCR (scanned pages in Auto mode, or every page in Always mode) |

- Apify platform usage is included. The only other charge is Apify's standard run-start event of $0.00005 per run ($0.05 per 1,000 runs).
- 1,000 digital PDFs cost **$3.00**, whatever their page count (up to `maxPages`).
- A 20-page fully scanned PDF costs $0.003 + 20 × $0.004 = **$0.083**.
- Use `ocrMode: "never"` to guarantee you never pay for OCR.
- Failed PDFs are **not charged**. Set **Max charge per run** to cap spend. If the cap is reached mid-PDF, the remaining scanned pages are left un-OCR'd (`ocrSkippedPages`) and not charged.

### Limits and tips

- Tables are detected from **ruled lines**. Tables drawn with whitespace only (common in academic papers) stay as text in reading order.
- OCR reads printed text well, but handwriting and very low-quality scans give poor results. Check `pages[].ocrConfidence`.
- Multi-column layouts come out column by column in most PDFs, but complex magazine layouts can interleave.
- Very large outputs: if the Markdown exceeds 2 MB, the full file is saved to the run's key-value store and linked in `markdownUrl`.

### FAQ

**Is this good for RAG?** Yes. Split `markdown` on `<!-- page N -->` markers or headings, and use `tables[].rows` for structured data.

**Are my PDFs stored?** PDFs are downloaded into the run's container, processed locally (no third-party APIs) and deleted when the run ends. Results stay in your own Apify storage.

**Can I process PDFs from Google Drive or Dropbox?** Yes, if the link is a public direct-download link.

**Found a PDF that converts badly?** Open an issue on the **Issues** tab with the run link.

### Keywords

PDF to text, PDF to Markdown, PDF table extraction, PDF table extractor, extract tables from PDF, PDF OCR, scanned PDF to text, PDF parser, PDF text extractor, PDF for RAG, PDF to LLM, document parsing, bulk PDF converter, invoice PDF, pdfplumber, Tesseract

***

Made by **Gigsmith**.

# Actor input Schema

## `fileUrls` (type: `array`):

Public http(s) links to PDF files.

## `uploadedFiles` (type: `array`):

Upload PDFs from your computer. They are stored in your own Apify key-value store.

## `ocrMode` (type: `string`):

auto: OCR only pages with no usable text layer (scans, photos). always: OCR every page. never: text layer only, no OCR charges.

## `ocrLanguages` (type: `array`):

Languages in the scanned pages. Default: English.

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

Detect ruled tables, return them as rows and as Markdown tables, and keep their text out of the body text.

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

Add a pages array with the text of every page and whether it was OCR'd.

## `pdfPassword` (type: `string`):

Password for protected PDFs. Applied to every PDF in this run.

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

Pages after this are skipped.

## `ocrMinChars` (type: `integer`):

In auto mode, a page with fewer text-layer characters than this is treated as scanned and OCR'd.

## `ocrDpi` (type: `integer`):

Higher is more accurate on small print but slower.

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

How many PDFs to process at once.

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

Larger PDFs are skipped and not charged.

## Actor input object example

```json
{
  "fileUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ],
  "ocrMode": "auto",
  "ocrLanguages": [
    "eng"
  ],
  "extractTables": true,
  "includePages": true,
  "maxPages": 500,
  "ocrMinChars": 25,
  "ocrDpi": 300,
  "maxConcurrency": 1,
  "maxFileSizeMb": 200
}
```

# Actor output Schema

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

Default dataset items, shown in the "Overview" view.

## `tablesView` (type: `string`):

Default dataset items, shown in the "Tables" view.

## `pagesView` (type: `string`):

Default dataset items, shown in the "Pages" view.

## `runSummary` (type: `string`):

JSON summary of the run: files processed, ok/error/skipped counts and charged events.

# 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 = {
    "fileUrls": [
        "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("gigsmith/pdf-to-text-markdown-tables").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 = { "fileUrls": ["https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"] }

# Run the Actor and wait for it to finish
run = client.actor("gigsmith/pdf-to-text-markdown-tables").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 '{
  "fileUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
  ]
}' |
apify call gigsmith/pdf-to-text-markdown-tables --silent --output-dataset

```

## MCP server setup

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

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/bFbE2fGM5NqPrP6Gz/builds/8GrtlsDlOqfczHFdc/openapi.json
