# CJK Document OCR — Vertical Text & Tables (Chinese, Japanese) (`domiq/cjk-document-ocr`) Actor

OCR for Traditional/Simplified Chinese and Japanese scans and PDFs. Auto-detects vertical (直書/縦書き) or horizontal text and the language, keeps reading order, and turns tables into CSV. Open-source engines only: files are never sent to third-party OCR services.

- **URL**: https://apify.com/domiq/cjk-document-ocr.md
- **Developed by:** [Domiq Data](https://apify.com/domiq) (community)
- **Features:** Limited permissions
- **Stats:** 1 total users, 0 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $4.80 / 1,000 page ocr'ds

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

## CJK Document OCR — Vertical Text & Tables

OCR for **Traditional Chinese, Simplified Chinese and Japanese** scans, photos and PDFs. It works out
for each page whether the text runs **vertically (直書 / 縦書き) or horizontally** and which language it is in,
returns the text **in the right reading order**, and turns **tables into CSV**.

繁體中文・简体中文・日本語の文書 OCR。直書/縦書き・横書きと言語を自動判定し、表は CSV で出力します。

### Why this Actor

- **Vertical text that actually works.** Most OCR tools read vertical Chinese and Japanese pages as
  garbage or in the wrong order. This Actor detects vertical pages and reads them column by column,
  right to left.
- **Tables as CSV.** Rows and columns are rebuilt from the layout, so a scanned price list or
  statistics table comes back as a spreadsheet, not a jumble of numbers.
- **Automatic language and script detection**, per page: Japanese, Traditional or Simplified Chinese.
  Stray characters from the wrong Chinese script (项目 on a Traditional page) are corrected.
- **Your documents stay private.** Only open-source OCR engines (RapidOCR / PP-OCRv6 and Tesseract)
  run inside the Actor. Files are **not sent to Google, Microsoft or any other OCR service**, are
  never stored, and are discarded after processing. Logs contain no document text.
- **Digital PDFs are free.** Pages that already have a text layer are returned as-is without an
  OCR charge.

### Accuracy

Measured on the public [CJK OCR benchmark](https://github.com/paulexi/cjk-ocr-benchmark): degraded
"scanned" pages with exact ground truth. Character error rate, lower is better.

| Category | This Actor | Other OCR Actors on Apify Store (range) |
|---|---|---|
| Traditional Chinese, horizontal | 0.3% | 1.6% – 98% |
| Simplified Chinese, horizontal | 0.1% | 0.1% – 57% |
| Traditional Chinese, vertical | 2.3% | 83% – 99% |
| Traditional Chinese, tables | 0.5% | 19% – 94% |
| **All Chinese pages** | **0.6%** | 25% – 87% |
| Japanese, horizontal | 1.9% | 34% – 75%\* |
| Japanese, vertical | 3.3% | 88% – 99%\* |

\* Competitors were measured on an earlier set of Japanese pages, which was replaced on
2026-11-27 so that every benchmark text is public domain in both Japan and the US. On that
earlier set this Actor scored 0.8% (horizontal) and 2.9% (vertical).

Table structure: all 3 benchmark tables come back with the correct number of rows and columns,
and 97% of cells are exactly right.

Honest comparison with a Google Lens–based Actor: Lens is slightly more accurate on ordinary
**horizontal** pages (e.g. 0.2% vs 0.3% on Traditional Chinese) and was perfect on a Japanese
vertical sample page. It failed on vertical **Traditional Chinese** (37% error vs 0.9%) and was
weaker on the table page (2.1% vs 0.1%), it returns no CSV, and it sends your files to Google. If
your documents are horizontal and may leave your control, Lens is a fine choice; for Traditional
Chinese vertical text, tables, or private documents, use this Actor.

Old-form kanji (舊字體, e.g. 爲, 隱) are often returned in their modern form.

### How to use

1. Paste links to your files in **Image or PDF URLs** (JPEG, PNG, WEBP, TIFF incl. multi-page,
   BMP, GIF, PDF). Or put many links in a .txt / .csv file and give its link in **URL list file**.
2. Leave **Language** on Auto unless all documents are in one language.
3. Run. Each page becomes one item in the dataset; download as JSON, CSV or Excel, or use the API.

Files must be reachable by a public link (for example a pre-signed S3 / Google Cloud Storage URL,
or a Dropbox / Google Drive direct-download link).

### Input

| Field | Default | Description |
|---|---|---|
| `urls` | – | Image or PDF links, up to 200 per run. |
| `sourceListUrl` | – | Link to a .txt or .csv file with more links. |
| `languageHint` | `auto` | `auto`, `zh-Hant`, `zh-Hans` or `ja`. |
| `outputTables` | `true` | Return detected tables as CSV. |
| `outputMarkdown` | `false` | Also return each page as Markdown (tables as Markdown tables). |
| `normalizeScript` | `true` | Fix characters from the wrong Chinese script. |
| `useTextLayer` | `true` | Use a PDF's own text when it has one (free). |
| `maxPagesPerDocument` | `50` | Only the first N pages of each document. |

```json
{
  "urls": ["https://example.com/scans/contract.pdf", "https://example.com/scans/menu.jpg"],
  "languageHint": "auto",
  "outputTables": true
}
```

### Output (one item per page)

```json
{
  "url": "https://example.com/scans/price-list.jpg",
  "page": 1,
  "documentPages": 1,
  "source": "ocr",
  "orientation": "horizontal",
  "language": "zh-Hant",
  "text": "項目\t地區\t數量\t單價\t金額\t日期\t備註\n人有\t第69條由權\t9,323\t91,914\t856,914,222\t2026/04/15\t臺灣\n…",
  "confidence": 0.995,
  "tablesCsv": ["項目,地區,數量,單價,金額,日期,備註\n人有,第69條由權,\"9,323\",\"91,914\",\"856,914,222\",2026/04/15,臺灣\n…"],
  "processingMs": 5247
}
```

| Field | Meaning |
|---|---|
| `source` | `ocr`, or `text-layer` for PDF pages that already contained text. |
| `orientation` | `horizontal` or `vertical`. |
| `language` | `zh-Hant`, `zh-Hans`, `ja`, or `null` when no CJK text was found. |
| `text` | Plain text in reading order. Horizontal: one line per text line, wide gaps as tabs. Vertical: one line per column, right to left; blank line between paragraphs. |
| `markdown` | Only with `outputMarkdown`. |
| `tablesCsv` | One CSV string per table found on the page. |
| `confidence` | 0–1, average engine confidence. |
| `error` / `warning` | Present when a file or page could not be processed, or a page had no text. |

A run summary (pages, tables, failures) is stored in the key-value store under `OUTPUT`.

### Pricing

Pay per event — you pay only for results:

| Event | Price |
|---|---|
| Page OCR'd (text found) | $0.006 |
| Table extracted | $0.004 |
| Run start | $0.002 |

Not charged: PDF pages read from their text layer, blank pages, files or pages that failed.

Examples: a 20-page scanned contract ≈ **$0.12**. 1,000 scanned pages with 200 tables ≈ **$6.80**.
Set a maximum cost per run and the Actor stops cleanly when it is reached.

### Limits

- Up to 200 files per run, 20 MB and 50 pages per file. Images larger than 3,000 px are scaled down.
- Printed text only; handwriting is not supported.
- One reading direction per page (a page with mostly vertical text is read as vertical).
- Multi-column horizontal layouts (newspapers) are read line by line across columns.
- Tables are rebuilt from text positions; merged cells and nested tables may come out simplified.
- Only links on the public internet are accepted (no private or internal addresses).

### Privacy and your responsibility

Documents are downloaded, processed in memory inside the Actor run and discarded. Nothing is sent
to third-party services. Only process documents you have the right to process.

### Open-source components

RapidOCR and PP-OCRv6 models (Apache-2.0), Tesseract and tessdata models (Apache-2.0),
OpenCC (Apache-2.0), PDFium via pypdfium2 (Apache-2.0 / BSD-3-Clause), Pillow (MIT-CMU).
See `NOTICE.md`.

# Actor input Schema

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

Direct links to images (JPEG, PNG, WEBP, TIFF, BMP, GIF) or PDFs. Up to 200 per run; each file up to 20 MB and 50 pages.

## `sourceListUrl` (type: `string`):

Link to a .txt or .csv file containing more document URLs (one per line or in any cell). Combined with the list above; the 200-URL limit applies to the total.

## `languageHint` (type: `string`):

Leave on Auto to detect per page. Set it if all your documents are in one language (slightly faster for vertical text).

## `outputTables` (type: `boolean`):

Detect tables on horizontal pages and return each one as CSV (charged per table found).

## `outputMarkdown` (type: `boolean`):

Adds a Markdown version of each page (paragraphs, and tables as Markdown tables).

## `normalizeScript` (type: `boolean`):

On pages detected as Traditional Chinese, characters that exist only in Simplified Chinese are converted (e.g. 项目 → 項目), and vice versa. Characters valid in both scripts are never changed. Turn off for documents that deliberately mix both scripts.

## `useTextLayer` (type: `boolean`):

Pages of digital PDFs that already contain text are returned as-is, free of OCR charges. Turn off to force OCR on every page.

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

Only the first N pages of each PDF or multi-page TIFF are processed.

## Actor input object example

```json
{
  "urls": [
    "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_v_00_scan.jpg",
    "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_table_00_scan.jpg"
  ],
  "languageHint": "auto",
  "outputTables": true,
  "outputMarkdown": false,
  "normalizeScript": true,
  "useTextLayer": true,
  "maxPagesPerDocument": 50
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "urls": [
        "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_v_00_scan.jpg",
        "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_table_00_scan.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("domiq/cjk-document-ocr").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://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_v_00_scan.jpg",
        "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_table_00_scan.jpg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("domiq/cjk-document-ocr").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://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_v_00_scan.jpg",
    "https://raw.githubusercontent.com/paulexi/cjk-ocr-benchmark/main/images/tw_table_00_scan.jpg"
  ]
}' |
apify call domiq/cjk-document-ocr --silent --output-dataset

```

## MCP server setup

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

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/mWoxFch7QdsTYZ7Jv/builds/AtMZ0zitG8ardeF7X/openapi.json
