# PDF to Markdown Local Prototype

Local browser UI plus Python worker for converting digital and scanned PDFs to Markdown.

## Setup

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\setup.ps1
powershell -ExecutionPolicy Bypass -File .\scripts\install_tesseract_windows.ps1
```

## Run

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\run_worker.ps1
```

Open `app/index.html` in a browser, or open the hosted UI:

```text
https://orc.thanganhai.com/
```

The hosted UI uses the OCR worker on the computer that opens the page. On another computer, click `Cài đặt`, unzip the installer package, then run the installer for that operating system once:

Windows:

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\install_windows.ps1
```

Or double-click `Install ORC Local Windows.cmd` from the extracted installer folder.

The Windows installer tries to find Python 3.12 and can install it with `winget` when it is missing.

macOS:

```bash
bash scripts/install_macos.sh
```

Or double-click `Install ORC Local macOS.command` from the extracted installer folder.

The installer starts OCR Local in the background and registers it to start when the user signs in. It also opens the local offline UI at:

```text
http://127.0.0.1:8765/
```

After the hosted UI has loaded once, it registers a service worker so the app shell can be opened again offline. OCR still requires the local worker on that same computer.

## Backtest

```powershell
powershell -ExecutionPolicy Bypass -File .\scripts\backtest_sample.ps1
```

Outputs are written to `outputs/`.

After a successful conversion in the browser UI, use `Tải Markdown` to download the generated `.md` file directly from the browser.

Use `Dừng OCR` while a conversion is running to request cancellation. The current page-level OCR step may finish before the worker stops the job.

## Backtest status

The provided sample PDF is scan-only and routes to local OCR. The latest run used Tesseract with Vietnamese language data from `tools/tessdata`, produced Markdown under `outputs/`, and wrote the quality report/log next to it.
