# PDF & Image to Text - OCR, Scanned PDFs, Bulk Text Extraction (`cuestadata/pdf-image-text-extractor`) Actor

Extract text from PDFs and images in bulk. Uses the PDF text layer when present and OCR only for scanned pages, photos and screenshots. 7 languages, per-page output, confidence scores and line positions.

- **URL**: https://apify.com/cuestadata/pdf-image-text-extractor.md
- **Developed by:** [Cuesta Data](https://apify.com/cuestadata) (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 $2.40 / 1,000 ocr pages

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

### What does PDF & Image to Text do?

**PDF & Image to Text** extracts text from **PDFs, scanned documents, photos and screenshots** in bulk. Paste links to your files and get clean text back, per file or per page, ready for spreadsheets, databases, search indexes or AI pipelines.

It is smart about cost and speed: if a PDF already contains real text, that text is used directly. **OCR (optical character recognition) runs only on pages that need it**, such as scanned pages, images and photos of documents.

### Why use this text extractor?

- **Text layer first, OCR only where needed.** Digital PDFs are processed in milliseconds at a fraction of the OCR price. Mixed PDFs (some scanned pages) are handled page by page.
- **Scanned PDFs and images.** PNG, JPEG, WebP, GIF, BMP and multi-page TIFF. Small screenshots are automatically upscaled and contrast-corrected for better accuracy.
- **7 languages.** English, Spanish, French, German, Portuguese, Italian and Dutch, alone or combined.
- **Confidence scores.** Every OCR page gets a confidence score, so you can flag low-quality scans automatically.
- **Line positions (optional).** Get each OCR line with its bounding box and confidence for layout-aware processing.
- **Easy inputs.** Direct links, plus public Google Drive and Dropbox share links.
- **Fair per-page pricing.** Failed downloads, unsupported files and password errors are listed with a clear error code and are never charged.

### What can I use it for?

- **Document processing:** invoices, receipts, forms, contracts and letters into searchable text.
- **AI and RAG pipelines:** feed clean text from PDFs into LLMs, vector databases or agents (works with MCP).
- **Research and archives:** bulk-convert scanned reports, public records and old documents.
- **Data entry automation:** pull text from screenshots and photos into Google Sheets, Airtable or a CRM via Make, Zapier or n8n.
- **Compliance and search:** make document libraries full-text searchable.

### How to extract text from PDFs and images

1. Click **Try for free** / **Start**.
2. Paste links to your PDFs or images into **File URLs** (one per line).
3. Pick your **Document languages** (English by default).
4. Click **Start**. Results appear in the **Output** tab and can be downloaded as JSON, CSV, Excel or HTML.

### Input example

```json
{
    "urls": [
        "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
        "https://example.com/scanned-invoice.jpg"
    ],
    "languages": ["eng"],
    "ocrMode": "auto",
    "outputMode": "document"
}
```

### Output example

With **One row per file** (default), each file produces one item:

```json
{
    "url": "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "fileName": "fw9.pdf",
    "fileType": "pdf",
    "fileSizeBytes": 140815,
    "pageCount": 6,
    "pagesProcessed": 6,
    "truncated": false,
    "ocrPages": 0,
    "textLayerPages": 6,
    "avgOcrConfidence": null,
    "languages": ["eng"],
    "charCount": 38120,
    "wordCount": 6272,
    "metadata": { "Title": "2024 Form W-9", "Producer": "..." },
    "text": "Form W-9\n(Rev. March 2024)\nRequest for Taxpayer\nIdentification Number and Certification ...",
    "pages": [
        { "page": 1, "method": "text-layer", "text": "Form W-9 ...", "confidence": null, "charCount": 6890 }
    ],
    "error": null
}
```

For a scanned page, `method` is `"ocr"` and `confidence` is filled in (for example `93.7`). With **Include lines** turned on, OCR pages also contain:

```json
"lines": [
    { "text": "Form W-9", "confidence": 93.5, "box": { "x": 156, "y": 175, "width": 248, "height": 90 } }
],
"imageSize": { "width": 2550, "height": 3300 }
```

Errors look like this and are **not charged**:

```json
{ "url": "https://example.com/missing.pdf", "error": "Download failed with HTTP 404", "errorCode": "HTTP_404" }
```

Error codes: `INVALID_URL`, `HTTP_<status>`, `DOWNLOAD_FAILED`, `FILE_TOO_LARGE` (over 100 MB), `UNSUPPORTED_TYPE`, `CORRUPT_FILE`, `PDF_PASSWORD`.

### How much does it cost?

This Actor uses **pay-per-event** pricing, charged per page:

- **OCR page** (scanned PDF page or image): see the Pricing tab, about $3 per 1,000 pages.
- **Text-layer page** (digital PDF page, no OCR needed): about $0.20 per 1,000 pages.

So a 10-page digital PDF costs about $0.002, and a 10-page scanned PDF about $0.03. Use **Max pages per file** to cap the cost of very large documents.

### Tips for best accuracy

- Choose every language present in your documents, and only those.
- For scanned PDFs, keep **OCR resolution** at 300 DPI. Use 200 for faster, cheaper runs on clean scans.
- Photos taken at an angle or in poor light reduce accuracy. Check `avgOcrConfidence`: values above 85 are usually very good.
- If a digital PDF's text comes out garbled (some PDFs have broken fonts), set **OCR mode** to *Always OCR*.
- For large batches, give the run 4-8 GB of memory: more memory means more CPU, so more pages are OCR'd in parallel.

### Integrations and API

Use it from the [Apify API](https://docs.apify.com/api/v2), the JavaScript or Python client, Make, Zapier, n8n, Google Sheets or any AI agent that supports MCP. Run it on a schedule or trigger it from a webhook when new files arrive.

### Use with AI agents (MCP)

Connect this tool to Claude, ChatGPT, Cursor or any other MCP client through the [Apify MCP server](https://docs.apify.com/mcp). Add this server URL to your client and sign in with your Apify account:

```json
{
  "mcpServers": {
    "apify": { "url": "https://mcp.apify.com/?tools=actors,docs,cuestadata/pdf-image-text-extractor" }
  }
}
```

Then ask in plain words, for example: *"Extract the text from these scanned PDF invoices, page by page."* The agent fills in the input, runs PDF & Image to Text (OCR) and reads the results.

AI agents without an Apify account can pay per run with a prepaid token (x402, Skyfire or card) through [Apify agentic payments](https://docs.apify.com/agents/payments). This tool uses limited permissions, so it works with those tokens.

### More tools from Cuesta Data

| Tool | What it does |
|---|---|
| [Website Screenshot & PDF](https://apify.com/cuestadata/website-screenshot-pdf) | Full-page, mobile and element screenshots or PDFs of any list of URLs, with change detection. |
| [Company Jobs API](https://apify.com/cuestadata/company-jobs-feed) | Every open job from company career pages on Greenhouse, Lever, Ashby, Workable and more. |
| [SEO Site Audit](https://apify.com/cuestadata/seo-site-audit) | Crawl a site and check titles, meta tags, headings, broken links, duplicates and schema, with an HTML report. |
| [PageSpeed & Lighthouse Bulk Audit](https://apify.com/cuestadata/pagespeed-lighthouse-audit) | Lighthouse scores, Core Web Vitals and top fixes for many URLs or a whole sitemap, with HTML reports. |
| [Domain Availability Checker](https://apify.com/cuestadata/domain-availability-checker) | Bulk domain availability for name ideas x TLDs, confirmed by registry RDAP/WHOIS, with registrar and expiry dates. |
| [Bulk File Downloader](https://apify.com/cuestadata/bulk-file-downloader) | Download files from a URL list or every PDF/image linked on a page, with one ZIP link and SHA-256 hashes. |
| [Link Preview & Website Metadata](https://apify.com/cuestadata/link-preview-metadata) | Title, description, Open Graph image, favicon, logo, brand color, JSON-LD and oEmbed for any list of URLs. |

### FAQ

**Are my documents stored?**
Files are downloaded only to process them and are not kept by this Actor. Extracted text is saved in your own Apify dataset, which you control and can delete.

**Can it read handwriting?**
Printed text works best. Neat handwriting is sometimes recognized, but results vary.

**Does it work with password-protected PDFs?**
Yes, if you provide the password in **PDF password**.

**Is it legal to extract text from documents?**
Extracting text from documents you own or have permission to process is generally fine. You are responsible for complying with copyright and privacy laws for the files you process.

**I found a bug or need a feature.**
Open an issue on the **Issues** tab. We usually reply within a day.

*PDF & Image to Text is built and maintained by Cuesta Data.*

# Actor input Schema

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

Links to PDFs or images (PNG, JPEG, WebP, GIF, TIFF, BMP). Google Drive and Dropbox share links work if the file is shared publicly.

## `languages` (type: `array`):

Languages used for OCR. Pick every language that appears in your documents (more languages = slightly slower).

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

Auto = use the PDF's own text when it has it and OCR only scanned pages (fastest, cheapest). Always = OCR every page. Never = text layer only, no OCR.

## `outputMode` (type: `string`):

One row per file (full text plus a pages array) or one row per page.

## `includeLines` (type: `boolean`):

For OCR pages, adds every text line with its confidence and bounding box (pixels of the processed image, see imageSize).

## `maxPagesPerFile` (type: `integer`):

Stops reading a PDF after this many pages. Protects you from paying for huge files by accident.

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

Resolution used to render scanned PDF pages for OCR. 300 is best for most documents; 200 is faster.

## `minTextCharsPerPage` (type: `integer`):

In Auto mode, PDF pages whose text layer has fewer characters than this are OCR'd instead.

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

Optional. Password for protected PDFs.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf"
  ],
  "languages": [
    "eng"
  ],
  "ocrMode": "auto",
  "outputMode": "document",
  "includeLines": false,
  "maxPagesPerFile": 200,
  "ocrDpi": 300,
  "minTextCharsPerPage": 25
}
```

# 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.irs.gov/pub/irs-pdf/fw9.pdf"
    ]
};

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

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

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,cuestadata/pdf-image-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/qntrh7p226rW4bkYP/builds/ICKOxbmnGa6zaQurQ/openapi.json
