# PDF & Image to Text - embedded text first, OCR only when needed (`forge_creations/pdf-image-to-text`) Actor

Extract text from PDFs and images by URL, page by page. Uses a PDF's own text when present ($0.50 per 1,000 pages) and Tesseract OCR only for scanned pages and images ($2 per 1,000), with a confidence score. Pages with no text are free.

- **URL**: https://apify.com/forge_creations/pdf-image-to-text.md
- **Developed by:** [Forge Creations](https://apify.com/forge_creations) (community)
- **Security:** 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 pdf page (embedded text)s

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 & Image to Text: embedded text first, OCR only when needed

Paste links to PDFs or images. You get the text back **page by page**:

- PDF pages that already contain text are read directly: exact and fast.
- Scanned PDF pages and images (PNG, JPEG, TIFF, GIF, WEBP, BMP) are read with **Tesseract OCR**, with a **mean confidence score** so you can filter weak pages.
- Each row says which method was used: `embedded-text` or `ocr`.

### Pricing

| What | Price |
|---|---|
| PDF page read from embedded text | $0.0005 ($0.50 per 1,000 pages) |
| Page or image read with OCR | $0.002 ($2 per 1,000) |
| Apify start fee | $0.00005 per run |

Pages that return no text, failed downloads and unsupported files are **not charged**. Set a maximum charge in run options to cap spending.

### Input

| Field | Default | Notes |
|---|---|---|
| fileUrls | required | Public http(s) links, 50 MB max per file |
| languages | eng | Tesseract codes joined by `+`; installed: eng, spa, fra, deu, por, ita |
| maxPagesPerFile | 50 | Pages read per PDF |
| ocrScannedPages | true | Turn off to read embedded text only (cheaper) |
| ocrDpi | 300 | Higher can help small print; slower |

### Output (one row per page)

`source_url, page, pages_total, file_type, method, text, chars, mean_confidence, language, status (ok | no_text | ocr_failed | download_failed | unsupported_type | unreadable_pdf), error`

### Limits

- Tesseract is good on clean printed text. It is weak on handwriting, photos of curved pages and complex tables. Check `mean_confidence`.
- Files must be reachable by URL without logging in.
- Layout is approximated: columns and tables come out as plain text lines.

### Support

Open an issue on the Issues tab with the file URL (if shareable) and run ID.

# Actor input Schema

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

Public http(s) links to PDFs or images (PNG, JPEG, TIFF, GIF, WEBP, BMP), max 50 MB each.

## `languages` (type: `string`):

Tesseract codes joined with +. Installed: eng, spa, fra, deu, por, ita. Example: eng+spa

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

Read at most this many pages from each PDF.

## `ocrScannedPages` (type: `boolean`):

Run OCR on PDF pages that have no embedded text (scanned pages). Turn off to read embedded text only.

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

Rendering resolution for OCR. Higher can help small print but is slower.

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

How many files are processed in parallel.

## Actor input object example

```json
{
  "fileUrls": [
    "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
    "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png"
  ],
  "languages": "eng",
  "maxPagesPerFile": 50,
  "ocrScannedPages": true,
  "ocrDpi": 300,
  "maxConcurrency": 2
}
```

# Actor output Schema

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

One row per page: method (embedded-text or ocr), OCR confidence, character count, status and the text.

# 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",
        "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forge_creations/pdf-image-to-text").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",
        "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("forge_creations/pdf-image-to-text").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",
    "https://raw.githubusercontent.com/tesseract-ocr/tessdoc/main/images/eurotext.png"
  ]
}' |
apify call forge_creations/pdf-image-to-text --silent --output-dataset

```

## MCP server setup

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

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/1yM13O6T7B9cXS48m/builds/OSRoLFue6gy8e2iy9/openapi.json
