# OCR PDF & Image to Excel (`tempting_adzuki/ocr-pdf-to-excel`) Actor

Extract tables and structured text from PDFs and images using OCR, then export the results to Excel. Supports scanned documents, multi-page PDFs, table reconstruction, merged headers, and noisy scans.

- **URL**: https://apify.com/tempting\_adzuki/ocr-pdf-to-excel.md
- **Developed by:** [Daniel Messias Leão da silva](https://apify.com/tempting_adzuki) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $20.00 / 1,000 pages

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

## OCR PDF & Image to Excel

Convert scanned PDFs and images into structured Excel workbooks using OCR.

OCR PDF & Image to Excel detects table-like structures, reconstructs rows and columns, and exports the extracted content to an XLSX file. It is designed for scanned documents and images where the original table data is not directly available as selectable text.

### What can it process?

The Actor supports:

- PDF documents from a direct file URL
- Images from a direct file URL
- Multi-page PDFs
- Tables with visible borders
- Borderless tables
- Merged headers
- Multi-row headers
- Weak or missing table borders
- Skewed scanned pages
- Noisy or lower-quality scans
- Tables with varying column widths
- Text, numeric, monetary, date, and formula-like cell content

OCR results depend on the quality and layout of the source document.

### How to use it

1. Open the Actor input.
2. Enter a direct URL to a PDF or image.
3. Select the OCR language.
4. Set the maximum number of PDF pages to process.
5. Run the Actor.
6. Open **Storage -> Key-value store**.
7. Download `OUTPUT.xlsx`.

For multi-page PDFs, each processed page is exported to its own worksheet.

### Input

#### `file_url`

Direct URL to the PDF or image to process.

#### `language`

OCR language used during recognition.

#### `max_pages`

Maximum number of PDF pages to process. This can be used to limit work on large documents.

### Output

The generated workbook is stored as `OUTPUT.xlsx` in the run's default Key-value store.

The Actor also writes one metadata record to the default Dataset, including:

- `status`
- `file_url`
- `source_type`
- `pages_processed`
- `rows_extracted`
- `ocr_language`
- `ocr_confidence`
- `output_file`

Example metadata:

```json
{
  "status": "OK",
  "file_url": "https://example.com/table.png",
  "source_type": "IMAGE",
  "pages_processed": 1,
  "rows_extracted": 6,
  "ocr_language": "eng",
  "ocr_confidence": 94.22,
  "output_file": "OUTPUT.xlsx"
}
```

### Example result

Here is a real example processed by the Actor.

**Source image**

![Example input table](https://api.apify.com/v2/key-value-stores/gGH74ZJs1eBDizMzE/records/example-input.jpg)

The input contains a table with 3 columns and 6 rows:

| Cell | Format | Formula |
|---|---|---|
| B4 | Percentage | None |
| C4 | General | None |
| D4 | Accounting | None |
| E4 | Currency | =PMT(B4/12,C4,D4) |
| F4 | Currency | =E4\*C4 |

**Generated Excel workbook**

The Actor detected the table structure and generated `OUTPUT.xlsx` with the same 3 columns and 6 rows, including the formula-like values.

This example was processed as a single image and exported to the `Page_1` worksheet.

### Excel workbook

The generated workbook provides:

- One worksheet per processed page
- Extracted rows and columns
- Bold first row
- Frozen first row
- Automatic filtering
- Automatic column-width adjustment
- Detected formulas preserved as text where appropriate

### Table reconstruction

The Actor combines OCR with structural table analysis. Depending on the document, it can use visible grid lines, recovered weak borders, recurring text positions, physical grid reconstruction, borderless-table anchors, merged-header detection, multi-line header recognition, adaptive deskew, and conservative multi-pass OCR correction.

### Pricing

The primary usage event is **$0.02 per successfully processed page**.

Examples:

- 1 page: $0.02
- 10 pages: $0.20
- 100 pages: $2.00
- 1,000 pages: $20.00

The Actor charges the page event only after OCR for that page completes successfully. Apify may show platform usage separately according to the user's plan.

### Tips for better results

- Use clear, readable source files.
- Prefer direct file URLs rather than webpage URLs.
- Select the correct OCR language.
- Test a small number of pages before processing a large PDF.
- Review the workbook when the source is heavily damaged or unusually formatted.

Handwriting and extremely low-resolution scans may require manual review.

### Privacy and responsible use

Only process documents that you are authorized to access and process. You are responsible for complying with applicable privacy, copyright, confidentiality, and data-protection requirements.

### Where to download the Excel file

After a successful run, open:

**Run -> Storage -> Key-value store -> OUTPUT.xlsx**

The Dataset contains processing metadata. The Excel workbook itself is stored in the Key-value store.

# Actor input Schema

## `file_url` (type: `string`):

Public HTTPS URL of a scanned PDF or image.

## `language` (type: `string`):

Language used by OCR.

## `max_pages` (type: `integer`):

Maximum number of PDF pages to process.

## Actor input object example

```json
{
  "file_url": "https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png",
  "language": "eng+por",
  "max_pages": 10
}
```

# 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 = {
    "file_url": "https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png"
};

// Run the Actor and wait for it to finish
const run = await client.actor("tempting_adzuki/ocr-pdf-to-excel").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 = { "file_url": "https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png" }

# Run the Actor and wait for it to finish
run = client.actor("tempting_adzuki/ocr-pdf-to-excel").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 '{
  "file_url": "https://raw.githubusercontent.com/eihli/image-table-ocr/master/resources/test_data/simple.png"
}' |
apify call tempting_adzuki/ocr-pdf-to-excel --silent --output-dataset

```

## MCP server setup

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

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/Grl5vhFehSwRs7yhe/builds/AaANkp0977XYz1Gx5/openapi.json
