LegacyLipi
Legacy Font PDF Translator - Translate PDF documents with legacy Indian font encodings to English.
Installation
From PyPI (Recommended)
pip install legacylipi
Or with uv:
uv tool install legacylipi
From Source
git clone https://github.com/biswasbiplob/legacylipi.git
cd legacylipi
uv sync
Frontend (for development)
cd frontend
npm install
Docker
Build and run with Docker:
# Build the image
docker build -t legacylipi .
# Run with Docker
docker run -p 8000:8000 legacylipi
# Or use Docker Compose
docker compose up
The web UI will be available at http://localhost:8000.
To process local files, mount volumes:
docker run -p 8000:8000 -v ./input:/app/input -v ./output:/app/output legacylipi
Usage
# CLI translation
legacylipi translate input.pdf -o output.txt
# Launch React web UI (production build served by FastAPI)
legacylipi api
# Launch legacy NiceGUI web UI (deprecated)
legacylipi ui
Problem
Millions of government documents, legal papers, and archival materials in Indian regional languages (Marathi, Hindi, Tamil, etc.) were created using legacy font encoding systems (Shree-Lipi, Kruti Dev, APS, Chanakya, etc.). These fonts map Devanagari/regional script glyphs to ASCII/Latin code points, making them unreadable by standard translation tools.
Example:
- What the PDF displays: महाराष्ट्र राजभाषा अधिनियम
- What text extraction produces:
´ÖÆüÖ¸üÖ™Òü ¸üÖ•Ö³ÖÖÂÖÖ †×¬Ö×®ÖμÖ´Ö - What Google Translate sees: Gibberish
Solution
LegacyLipi:
- Detects the font encoding scheme used in a PDF (legacy or Unicode)
- Converts legacy-encoded text to proper Unicode
- Alternatively, uses OCR to extract text from scanned PDFs
- Translates the Unicode text to the target language
- Outputs translated text in various formats (text, markdown, PDF)
Installation
# Clone and install
git clone https://github.com/biswasbiplob/legacylipi.git
cd legacylipi
uv sync
# With all optional backends
uv sync --all-extras
OCR Support (Optional)
LegacyLipi supports multiple OCR backends:
| Backend | Description | GPU Support |
|---|---|---|
| Tesseract | Local, free, most language packs | CPU only |
| Google Vision | Cloud, paid, best accuracy | N/A |
| EasyOCR | Local, free, good for Indian languages | CUDA, MPS (Apple Silicon) |
Tesseract (default):
# Ubuntu/Debian
sudo apt-get install tesseract-ocr tesseract-ocr-mar tesseract-ocr-hin
# macOS
brew install tesseract tesseract-lang
EasyOCR with GPU (optional):
# Install with EasyOCR support
uv sync --extra easyocr
# For GPU acceleration, install PyTorch with CUDA or MPS support
Google Vision (optional):
uv sync --extra vision
# Requires GCP credentials (GOOGLE_APPLICATION_CREDENTIALS)
See docs/cli-reference.md for detailed OCR options and language codes.
Quick Start
# Basic translation
uv run legacylipi translate input.pdf -o output.txt
# Output as PDF (preserves layout)
uv run legacylipi translate input.pdf -o output.pdf --format pdf
# OCR for scanned documents
uv run legacylipi translate input.pdf --use-ocr -o output.txt
# Use local LLM (requires Ollama)
uv run legacylipi translate input.pdf --translator ollama --model llama3.2
# Detect encoding only
uv run legacylipi detect input.pdf
See docs/cli-reference.md for complete CLI documentation.
Web UI
LegacyLipi includes a modern React-based web interface backed by a FastAPI REST API.
Production (single command)
# Serves the built React frontend + API on one port
uv run legacylipi api
# or
uv run legacylipi-web
Open http://localhost:8000 in your browser.
Development (hot-reload)
# Start both FastAPI backend and Vite dev server
./scripts/dev.sh
This runs:
- Backend at http://localhost:8000 (FastAPI with auto-reload)
- Frontend at http://localhost:5173 (Vite dev server with HMR, proxies
/apito backend)
Legacy NiceGUI UI (deprecated)
The original NiceGUI-based UI is still available but deprecated:
uv run legacylipi ui
# Open http://localhost:8080
Workflow Modes:
- Scanned Copy - Create image-based PDF copy (adjust DPI, color, quality)
- Convert to Unicode - OCR + Unicode conversion without translation
- Full Translation - Complete pipeline with OCR, conversion, and translation
Features:
- Drag-and-drop PDF upload
- Workflow-based UI with mode selection
- Multiple translation backends (Translate-Shell, Google, Ollama, OpenAI, etc.)
- OCR support with engine and language selection
- Structure-preserving or flowing text modes
- Real-time SSE progress streaming
- Direct download of translated files
- Responsive dark-theme design
Translation Backends
| Backend | Description | Setup |
|---|---|---|
trans |
translate-shell CLI (recommended) | brew install translate-shell |
google |
Google Translate (free API) | Works out of the box |
mymemory |
MyMemory API (free) | Works out of the box |
ollama |
Local LLM via Ollama | Ollama required |
openai |
OpenAI GPT models | Set OPENAI_API_KEY |
gcp_cloud |
Google Cloud Translation | GCP project + credentials |
See docs/translation-backends.md for detailed setup guides.
Supported Encodings
| Encoding | Font Family | Language | Status |
|---|---|---|---|
| shree-lipi | Shree-Lipi, Shree-Dev-0714 | Marathi | ✅ Built-in |
| kruti-dev | Kruti Dev | Hindi | ✅ Built-in |
| aps-dv | APS-DV | Hindi | 🔄 Detection only |
| chanakya | Chanakya | Hindi | 🔄 Detection only |
| dvb-tt | DVB-TT, DV-TTYogesh | Hindi | 🔄 Detection only |
| walkman-chanakya | Walkman Chanakya | Hindi | 🔄 Detection only |
| shusha | Shusha | Hindi | 🔄 Detection only |
CLI Commands
| Command | Description |
|---|---|
api |
Launch the React web UI + FastAPI REST API |
translate |
Full pipeline: parse → detect → convert → translate → output |
convert |
Convert legacy encoding to Unicode (no translation) |
extract |
Extract text from PDF (OCR or font-based) |
detect |
Analyze PDF and report detected encoding |
scan-copy |
Create an image-based scanned copy of a PDF |
encodings |
List supported font encodings |
usage |
Show API usage statistics |
ui |
Launch legacy NiceGUI web interface (deprecated) |
See docs/cli-reference.md for full command reference.
Development
See docs/development.md for setup instructions, running tests, project structure, and adding new encodings.
Architecture
┌─────────────────────────────────────────────────────────────────────────┐
│ LegacyLipi │
├─────────────────────┬───────────────────────────────────────────────────┤
│ React Frontend │ FastAPI Backend │
│ (Vite + TS + TW) │ │
│ │ ┌──────────────────────────────────────────┐ │
│ FileUploader │ │ REST API │ │
│ WorkflowSelector │ │ /api/v1/config/* GET config │ │
│ Settings panels │◄─▶│ /api/v1/sessions/* Upload/delete │ │
│ StatusPanel (SSE) │ │ /api/v1/sessions/*/ Start pipeline │ │
│ DownloadButton │ │ /api/v1/sessions/*/progress SSE stream │ │
│ │ │ /api/v1/sessions/*/download Get result │ │
│ │ └────────────────────┬─────────────────────┘ │
├─────────────────────┘ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────────────────────┐ │
│ │ Core Pipeline │ │
│ │ │ │
│ │ PDF Parser / OCR Parser │ │
│ │ │ │ │
│ │ Encoding Detector → Unicode Converter │ │
│ │ │ │ │
│ │ Translation Engine (trans, Google, Ollama, OpenAI, GCP, ...) │ │
│ │ │ │ │
│ │ Output Generator (.txt, .md, .pdf) │ │
│ └──────────────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────────────┘
Pipeline Flow:
- Parse PDF → Extract text with PDF parser or OCR
- Detect Encoding → Identify legacy encoding scheme
- Convert to Unicode → Transform legacy text to Unicode
- Translate → Use translation backend
- Generate Output → Create PDF/text/markdown
License
MIT
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests (
uv run pytest) - Commit and push
- Open a Pull Request
Metadata
Release files for legacylipi 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| legacylipi-1.0.2.tar.gz | 21.8 MB | Without provenance | Details for legacylipi-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| legacylipi-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for legacylipi-1.0.2-py3-none-any.whl |
Total release size: 22.3 MB
Release files / legacylipi-1.0.2.tar.gz
| Download URL | legacylipi-1.0.2.tar.gz |
|---|---|
| Size | 21.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
bfce6c9e10cb38b6d76976d9bf64568bd47047be4ad792c50226c9323275d065
|
|
BLAKE2b-256 checksum How to use checksums |
544753ecec5c9dc19987be9066153c752229823623e2f9bb131d4cf7606155dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Release files / legacylipi-1.0.2-py3-none-any.whl
| Download URL | legacylipi-1.0.2-py3-none-any.whl |
|---|---|
| Size | 528.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3000e126a905d62a1a7c80ad099f47f3552d654803922ed3e2f7885d54955d32
|
|
BLAKE2b-256 checksum How to use checksums |
b9477ca801d99765133820c7bbd137a03591aea0881b9ad49bae087aebe91e81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Security for legacylipi 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.