# OCR Citation Chunker (`skilled_glee/ocr-citation-chunker`) Actor

Convert scanned or image-based PDFs into page-aware, citation-ready JSON chunks with OCR confidence for RAG, search, and agent workflows.

- **URL**: https://apify.com/skilled\_glee/ocr-citation-chunker.md
- **Developed by:** [Dakota Myers](https://apify.com/skilled_glee) (community)
- **Categories:** Developer tools, AI, Automation
- **Stats:** 2 total users, 1 monthly users, 57.1% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.20 / 1,000 useful ocr page processeds

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## OCR Citation Chunker

Give this Actor a scanned or image-only PDF and it returns deterministic, page-aware citation-ready JSON chunks with OCR confidence, quality signals, source provenance, and stable citation identifiers.

Use it to turn archival scans, printed reports, forms, and image-based research PDFs into retrieval-ready records for RAG, search, and agent workflows. It is intentionally narrow: it processes PDFs, does not interpret their meaning, and never invents text.

### Input

Provide either a single `url` or a batch in `urls`. The Actor downloads each PDF, runs Tesseract OCR page by page, and groups usable text into chunks without crossing document boundaries. `chunkSize` controls the approximate maximum characters per chunk; `overlap` retains trailing context in the next chunk.

```json
{
  "url": "https://example.com/scanned-report.pdf",
  "chunkSize": 1000,
  "overlap": 100
}
```

PDF URLs must be publicly reachable. Password-protected, malformed, or unreachable inputs are reported in the final `SUMMARY`; a failed document does not discard usable output from other documents in the same run.

### Output

The default dataset contains one JSON record per citation-ready chunk. Important fields include:

- `text`, `pageStart`, and `pageEnd` for grounding a citation.
- `documentId` (SHA-256 of source bytes) and deterministic `chunkId` for idempotent downstream indexing.
- `sourceUrl`, `resolvedUrl`, `sourceByteSize`, and `documentSha256` for provenance.
- `ocrConfidence` plus `ocrQualityScore`, `ocrQualityTier` (`high`, `usable`, or `low`), and `ocrQualityFlags` for filtering uncertain extraction.
- `characterCount` and `estimatedTokens` to help size vector-store or LLM work.

The key-value store record `SUMMARY` reports totals, per-document outcomes, failed URLs, and average OCR quality. A useful OCR page is one that produces usable text and saved citation-ready output. Blank or non-readable pages are not emitted as chunks, are not charged as useful OCR pages, and are reflected in document outcomes.

### Example record

```json
{
  "documentId": "sha256:...",
  "chunkId": "sha256:...",
  "pageStart": 4,
  "pageEnd": 4,
  "ocrConfidence": 92.4,
  "ocrQualityScore": 94.1,
  "ocrQualityTier": "high",
  "ocrQualityFlags": [],
  "text": "Extracted source text..."
}
```

### Limits and quality

OCR is best for clear, reasonably upright scans. Handwriting, complex tables, faint pages, unusual scripts, and heavily compressed imagery may produce incomplete text. Use `ocrQualityTier` and `ocrQualityFlags` as deterministic review signals before relying on a chunk. The Actor currently targets English OCR.

The production configuration uses 512 MB with `OMP_THREAD_LIMIT=1`. A clean 50-page cloud control completed successfully with stable late-page timing. Actual cost varies with page count, image resolution, and source quality. See `BENCHMARKS.md` in the source for measured fixtures and run evidence.

### Pricing

The Actor uses pay-per-event pricing. It charges once for each useful OCR page only after that page's citation-ready output is saved. Blank pages that produce no useful output are not charged as `page-processed` events. Platform usage costs are included.

| Subscription tier | Useful OCR page price |
| --- | ---: |
| Free / Bronze | $1.50 per 1,000 pages |
| Silver | $1.35 per 1,000 pages |
| Gold and higher | $1.20 per 1,000 pages |

Actor start is $0.00005 per run.

### Integration

Consume the dataset through the Apify API, webhook, Make, Zapier, or an agent workflow. Store `chunkId` to deduplicate re-runs, cite `sourceUrl` with `pageStart`/`pageEnd`, and retain `documentId` to trace every chunk back to its exact source bytes.

### For AI agents and MCP

**Contract:** public scanned or image-only PDF URL → OCR-backed, page-aware citation-ready JSON chunks.

Use this Actor for scanned PDF OCR, image-only PDFs, OCR to JSON, citation-ready OCR, and scanned-document RAG ingestion. For PDFs with an embedded text layer, use **PDF Citation Chunker** instead.

# Actor input Schema

## `url` (type: `string`):

A single public PDF URL to process with OCR.

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

Optional batch of up to 10 public PDF URLs.

## `chunkSize` (type: `integer`):

Maximum characters per chunk.

## `overlap` (type: `integer`):

How many characters overlap between adjacent chunks.

## Actor input object example

```json
{
  "url": "https://raw.githubusercontent.com/EchoEmpireUtility-bot/ocr-benchmark-fixtures/main/ocr-test-scan.pdf",
  "chunkSize": 1000,
  "overlap": 100
}
```

# Actor output Schema

## `citationChunks` (type: `string`):

Default dataset of useful page-aware OCR chunks. Blank pages with no useful text are omitted.

## `summary` (type: `string`):

SUMMARY record with document outcomes, useful OCR page and chunk totals, quality aggregates, unprocessed URLs, and final status.

# 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 = {
    "url": "https://raw.githubusercontent.com/EchoEmpireUtility-bot/ocr-benchmark-fixtures/main/ocr-test-scan.pdf",
    "chunkSize": 1000,
    "overlap": 100
};

// Run the Actor and wait for it to finish
const run = await client.actor("skilled_glee/ocr-citation-chunker").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 = {
    "url": "https://raw.githubusercontent.com/EchoEmpireUtility-bot/ocr-benchmark-fixtures/main/ocr-test-scan.pdf",
    "chunkSize": 1000,
    "overlap": 100,
}

# Run the Actor and wait for it to finish
run = client.actor("skilled_glee/ocr-citation-chunker").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 '{
  "url": "https://raw.githubusercontent.com/EchoEmpireUtility-bot/ocr-benchmark-fixtures/main/ocr-test-scan.pdf",
  "chunkSize": 1000,
  "overlap": 100
}' |
apify call skilled_glee/ocr-citation-chunker --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,skilled_glee/ocr-citation-chunker"
        }
    }
}

```

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/50meJWqJ27Aw2QYZD/builds/qmsswpURypk23jfwv/openapi.json
