# PDF & Image to Text - OCR Text Extractor (`pshivam/pdf-ocr-text-scraper`) Actor

Extract text from PDFs and images by link: the text layer of a PDF, OCR for scanned pages and pictures in 27 languages. Per-page text, metadata, word count and OCR confidence. Passwords, page ranges, many files. Export to Excel, CSV or API.

- **URL**: https://apify.com/pshivam/pdf-ocr-text-scraper.md
- **Developed by:** [Shivam Prajapati](https://apify.com/pshivam) (community)
- **Categories:** Automation, Developer tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.10 / 1,000 documents

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

## PDF & Image to Text - OCR Text Extractor

**Extract the text of PDFs and images by link: the text layer of a PDF, and OCR for scanned pages and pictures in 27 languages.** One record per file with the full text, the text of each page, metadata (title, author, dates), word count and the OCR confidence. Password-protected PDFs, page ranges, many files at once. Export to Excel, CSV, JSON or the API. No login, no API key.

**Actively maintained.** Last update: 2026-11-21. Every release passes 100+ automated tests on real PDFs and images, and the OCR is run on real pictures on Apify.

### What can you use it for?

- **Make PDFs searchable and analysable.** Invoices, contracts, reports, papers, forms: the text in a column, ready for search, spreadsheets or your own scripts.
- **Read scanned documents.** Scans, photos of documents, screenshots and fax-like PDFs have no text layer: the Actor recognises them with OCR.
- **Feed AI and search tools.** Clean text per page with the page numbers, for RAG, embeddings and summaries.
- **Process whole folders of links.** Hundreds of PDFs or images from a sitemap, a dataset or a spreadsheet, in one run.
- **Check metadata.** Title, author, creator, creation and modification dates of PDFs.

### What data can you get?

Give links. Every record is one file.

| You give | You get |
|---|---|
| `urls`: links to PDFs and images | One record per file with its text |
| `languages` | OCR in 27 languages, up to 4 at once |
| `ocrMode` | The text layer, OCR for pages without text (automatic), OCR everywhere, or never |
| `pages`, `maxPagesPerDocument` | Only some pages |
| `password` | Protected PDFs |

#### Fields

A field that does not apply, such as the author of an image, is `null`.

##### The file

| Field | What it is |
|---|---|
| `url` | The link you gave. |
| `finalUrl` | The address the file was downloaded from, after redirects. |
| `httpStatus` | The HTTP status of the download. |
| `fileType` | pdf, png, jpeg, gif, webp, tiff or bmp, known from the file's first bytes, not from its name. |
| `fileBytes` | The size of the downloaded file in bytes. |
| `pageCount` | How many pages the document has. |
| `pagesRead` | How many pages were read (the page range and the page limit apply). |

##### The text

| Field | What it is |
|---|---|
| `text` | The text of the pages read, pages separated by a blank line. |
| `pages` | The text of each page: a list of objects with page, text, method (textLayer or ocr) and confidence (OCR pages). Empty when 'Include the text of each page' is off. |
| `wordCount` | The number of words in text. |
| `characterCount` | The number of characters in text. |
| `method` | textLayer when every page came from the PDF's own text, ocr when every page was recognised, mixed for both. |
| `languages` | The OCR languages used, as Tesseract codes: eng, deu ... |
| `confidence` | The average OCR confidence of the recognised pages, 0 to 100. Empty when no page needed OCR. |

##### PDF details

| Field | What it is |
|---|---|
| `title` | The PDF's title from its metadata. |
| `author` | The PDF's author from its metadata. |
| `subject` | The PDF's subject from its metadata. |
| `keywords` | The PDF's keywords from its metadata. |
| `creator` | The program that created the document. |
| `producer` | The program that made the PDF file. |
| `createdAt` | When the PDF was created (UTC). |
| `modifiedAt` | When the PDF was last changed (UTC). |

##### Where it came from

| Field | What it is |
|---|---|
| `scrapedAt` | When the record was collected (UTC). |

#### Example result

A PDF with one page of real text and one scanned page (the OCR text is shown as an example):

```json
{"url": "https://example.com/report.pdf", "finalUrl": "https://example.com/report.pdf", "httpStatus": 200, "fileType": "pdf", "fileBytes": 183204, "pageCount": 2, "pagesRead": 2, "method": "mixed", "languages": ["eng"], "text": "A page with a real text layer, long enough to be used as it is.\n\nText recognised from a scanned page.", "pages": [{"page": 1, "text": "A page with a real text layer, long enough to be used as it is.", "method": "textLayer", "confidence": null}, {"page": 2, "text": "Text recognised from a scanned page.", "method": "ocr", "confidence": 91.5}], "wordCount": 21, "characterCount": 101, "confidence": 91.5, "scrapedAt": "2026-11-21T10:00:06Z"}
```

### Input

| Input | What it does |
|---|---|
| `urls` | Links to PDFs and images |
| `languages`, `ocrMode`, `dpi` | OCR languages, when to use OCR, the resolution |
| `pages`, `maxPagesPerDocument` | Which pages, and how many |
| `includePages` | The text of each page, or only the whole text |
| `password` | The password of protected PDFs |
| `onlyNew` | Skip files that earlier runs of the same input returned |
| `maxItems`, `maxConcurrency`, `requestTimeoutSeconds`, `proxyConfiguration` | Limits, speed and downloads |

### How much does it cost?

You pay per document returned, whatever its number of pages. There is no start fee. Files that cannot be downloaded or read are not returned and not charged.

| Plan | Price per 1,000 documents |
|---|---|
| Free | $3.00 |
| Bronze | $2.70 |
| Silver | $2.40 |
| Gold | $2.10 |

- 1,000 documents cost about $3 on the Free plan. OCR also uses run time: a scanned page takes 1 to 3 seconds of the run, which Apify bills as platform usage.
- Use `maxItems` to cap the cost of a run, and `maxPagesPerDocument` to cap the OCR time.

### Use it via API, on a schedule, or with your tools

```python
from apify_client import ApifyClient

client = ApifyClient("<YOUR_API_TOKEN>")
run = client.actor("pshivam/pdf-ocr-text-scraper").call(run_input={
    "urls": ["https://example.com/invoice.pdf", "https://example.com/scan.png"],
    "languages": ["eng", "deu"],
    "ocrMode": "auto",
})
for doc in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(doc["url"], doc["method"], doc["wordCount"], doc["text"][:100])
```

#### Use it in Clay, n8n, Make or Zapier

Use the Actor ID `pshivam/pdf-ocr-text-scraper` and an input like this:

```json
{"urls": ["https://example.com/contract.pdf"], "includePages": false, "maxPagesPerDocument": 100}
```

### Good to know

- **Text layer first.** In automatic mode a PDF page that has real text is read from the PDF itself: exact and fast. OCR runs only for pages without text, and for images. A scanned PDF is read page by page with OCR.
- **OCR quality.** Tesseract reads clear print well. Handwriting, very small or blurred text and photos taken at an angle give lower `confidence`: raise `dpi` to 300 for small print. Choose the right `languages`: a German text read as English loses its umlauts.
- **Files by link.** The Actor downloads each file (up to 100 MB). It cannot read files behind a login. For files on your computer, upload them to a public link first.
- **No layout.** The text comes in reading order, line by line, and a blank line between blocks. Tables become lines of text, not cells.
- **Speed.** A PDF with a text layer takes under a second. A scanned page takes 1 to 3 seconds of OCR, so a 50-page scan takes 1 to 2 minutes.
- **Independent tool.** Not affiliated with Adobe or the Tesseract project. Check an important figure in the original document.

### FAQ

#### How do I extract text from a PDF?

Put the link in `urls` and run. A PDF with a text layer is read directly, with the text of each page.

#### Can it read scanned PDFs and images?

Yes. Pages without text, and every image, are recognised with OCR. Choose the languages of the text in `languages`.

#### Which languages does the OCR support?

27, among them English, German, French, Spanish, Portuguese, Italian, Dutch, Russian, Arabic, Chinese, Japanese, Korean, Hindi and Turkish. Use up to four in one run.

#### What about password-protected PDFs?

Give the password in `password`. The same password is tried on every protected file.

#### How accurate is the OCR?

Each recognised page has a `confidence` from 0 to 100. Clear print scores above 90. Use `ocrMode` "never" to skip OCR when you only want text layers.

#### Can I read only some pages?

Yes. `pages` takes a range such as 1-3,5 and `maxPagesPerDocument` caps the pages of each file.

# Actor input Schema

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

The files to read, one link per line: PDF, PNG, JPEG, TIFF, WEBP, GIF or BMP. The file's type is known from its first bytes, so a link without an extension works. Leave empty to read two example files.

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

The languages of the text in scanned pages and images. Choose all the languages the text has (up to 4). OCR is exact only for the languages chosen. PDF text layers need no language.

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

Automatic reads a PDF page's own text and uses OCR only when the page has none. 'OCR every page' ignores the text layer: use it for PDFs whose text layer is wrong. 'Text layer only' never runs OCR.

## `pages` (type: `string`):

Read only these pages of each document: 1-3, 5 or 4- (page 4 to the end). Leave empty to read all pages.

## `maxPagesPerDocument` (type: `integer`):

Read at most this many pages of each document. OCR takes about 1 to 3 seconds a page.

## `dpi` (type: `integer`):

The resolution at which PDF pages are drawn before OCR. 200 is right for normal print; 300 for small text; 100 is faster and less exact.

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

Add the text, method and OCR confidence of every page in `pages`. Turn it off for smaller records: `text` always has everything.

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

The password of protected PDFs. The same password is tried on every protected file.

## `requestTimeoutSeconds` (type: `integer`):

Give up on a file that has not downloaded after this many seconds.

## `onlyNew` (type: `boolean`):

Skip documents that earlier runs of this same input already returned, so you get and pay for new ones only. The first run works as usual and remembers what it returned, in your key-value store 'pdf-ocr-text-scraper-only-new'.

## `maxItems` (type: `integer`):

Stop after this many documents. You are charged per document returned.

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

How many files are read at the same time. OCR uses a lot of processor: raise it only with more memory and CPU in the run's settings.

## `proxyConfiguration` (type: `object`):

Not needed to start. Turn it on only if a server refuses the Actor's address; the proxy then takes over while the address rests.

## Actor input object example

```json
{
  "urls": [
    "https://www.irs.gov/pub/irs-pdf/fw9.pdf",
    "https://tesseract.projectnaptha.com/img/eng_bw.png"
  ],
  "languages": [
    "eng"
  ],
  "ocrMode": "auto",
  "maxPagesPerDocument": 20,
  "dpi": 200,
  "includePages": true,
  "requestTimeoutSeconds": 60,
  "onlyNew": false,
  "maxItems": 50,
  "maxConcurrency": 2,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `documents` (type: `string`):

Documents as a table.

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

Requests made, time spent and number of records for this run (RUN_STATS record).

# 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",
        "https://tesseract.projectnaptha.com/img/eng_bw.png"
    ],
    "languages": [
        "eng"
    ],
    "maxPagesPerDocument": 20,
    "maxItems": 50,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("pshivam/pdf-ocr-text-scraper").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",
        "https://tesseract.projectnaptha.com/img/eng_bw.png",
    ],
    "languages": ["eng"],
    "maxPagesPerDocument": 20,
    "maxItems": 50,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("pshivam/pdf-ocr-text-scraper").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",
    "https://tesseract.projectnaptha.com/img/eng_bw.png"
  ],
  "languages": [
    "eng"
  ],
  "maxPagesPerDocument": 20,
  "maxItems": 50,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call pshivam/pdf-ocr-text-scraper --silent --output-dataset

```

## MCP server setup

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

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/pTJdFwJCfIFOIgJdZ/builds/kHOdeswaW52k3T6lT/openapi.json
