# PDF & Image to Text and Data – AI OCR (`publicrows/document-to-data`) Actor

Turn PDFs and images into text and data: full text per page with tables as Markdown, document type and language, plus any fields you name (invoice number, total, date...) picked out per page. Claude reads scans and photos too. $4 per 1,000 pages, first 3 free.

- **URL**: https://apify.com/publicrows/document-to-data.md
- **Developed by:** [PublicRows](https://apify.com/publicrows) (community)
- **Categories:** AI, Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.80 / 1,000 pages read

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/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 and Data – AI OCR

Turn PDFs and images into text and data: full text per page with tables as Markdown, document type and language, plus any fields you name (invoice number, total, date...) picked out per page. Claude reads scans and photos too. $4 per 1,000 pages, first 3 free.

### Who this is for

Operations and finance teams digitising invoices, receipts and forms, developers who need OCR inside a pipeline without hosting a model, and AI agents that must read a PDF before they can answer: file URLs in, one clean row per page out.

### Sample output

```json
{
  "file_url": "...",
  "page_number": "...",
  "document_type": "...",
  "language": "...",
  "text": "...",
  "fields_found": "...",
  "ai_model": "...",
  "row_key": "..."
}
```

### What you get

One row per page. Every row also carries `_source` (attribution) and the recipe version.

| Field | Type |
| --- | --- |
| `file_url` | string, always present |
| `page_number` | number, always present |
| `document_type` | string |
| `language` | string |
| `text` | string, always present |
| `fields_found` | string |
| `ai_model` | string |
| `row_key` | string, always present |
| `source_url` | string |

Each file is read by Claude from its URL, so the link must be publicly reachable (a signed or expiring link works if it is valid during the run). Scanned PDFs, photos of receipts and screenshots are read like text PDFs.

`text` is a faithful transcription, not a summary; tables come out as Markdown. `fields_found` lists `{name, value}` pairs for the fields you ask for, per page, values exactly as printed.

Billing is per page: a 10-page PDF is 10 rows. Very large PDFs (over 100 pages) should be split first.

### Pricing

Pay per page: $0.004 each ($4.00 per 1,000). The first 3 rows of every run are free, so a test costs nothing.

### How to run

1. Keep the defaults for the standard sample, or set the inputs (listed last, below).
2. Run. Results land in the dataset as JSON, CSV or Excel.
3. From code or an agent: call it through the API, or as an MCP tool via mcp.apify.com.

### Source and fair use

Data: the buyer's documents, read by Claude (Anthropic API). The data is bought from the supplier under its API terms on every run; nothing is scraped from any website. Rows are facts about pages, and no personal data of individuals is included.

### FAQ

**How fresh is the data?** Each run fetches live from the source.
**Can I get more fields?** Open an issue naming the field and where it appears at the source.
**Something broke?** Open an issue. Issues are answered within 12 hours.
**Found it useful?** A short review on this page helps other people find it, and tells us what to improve.

### Inputs

- `fileUrls`: Public URLs of PDFs or images (PNG, JPG, GIF, WebP), one per line. Each file is read once; a PDF gives one row per page. Up to 100 pages per PDF.
- `fieldsToExtract`: Optional: the fields you want picked out, comma-separated ("invoice number, invoice date, total, VAT number, supplier name"). They come back per page in fields_found.
- `anthropicKey`: Optional: your own Anthropic API key (sk-ant-...). Leave empty to use the actor's own; the price is the same either way.
- `maxItems`: Stop after this many rows.

# Actor input Schema

## `fileUrls` (type: `string`):

Public URLs of PDFs or images (PNG, JPG, GIF, WebP), one per line. Each file is read once; a PDF gives one row per page. Up to 100 pages per PDF.

## `fieldsToExtract` (type: `string`):

Optional: the fields you want picked out, comma-separated ("invoice number, invoice date, total, VAT number, supplier name"). They come back per page in fields_found.

## `anthropicKey` (type: `string`):

Optional: your own Anthropic API key (sk-ant-...). Leave empty to use the actor's own; the price is the same either way.

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

Stop after this many rows.

## Actor input object example

```json
{
  "fileUrls": "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf",
  "fieldsToExtract": "",
  "maxItems": 2000
}
```

# Actor output Schema

## `rows` (type: `string`):

Dataset items, one per page (file_url, page_number, document_type, language, text, fields_found, ai_model, row_key, source_url). Append ?format=csv or ?format=xlsx for other formats.

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

Pages fetched, response classes, cost estimate and the quality-gate checks for this run.

# 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",
    "fieldsToExtract": "",
    "maxItems": 2000
};

// Run the Actor and wait for it to finish
const run = await client.actor("publicrows/document-to-data").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",
    "fieldsToExtract": "",
    "maxItems": 2000,
}

# Run the Actor and wait for it to finish
run = client.actor("publicrows/document-to-data").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",
  "fieldsToExtract": "",
  "maxItems": 2000
}' |
apify call publicrows/document-to-data --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,publicrows/document-to-data"
        }
    }
}
```

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/rd3kEr0Qevzc0dAaK/builds/hp7zlBrmt46gyscUI/openapi.json
