About this project

BabelDOC is an open-source document translation tool designed to translate PDF files while preserving the original layout, formatting, and structure. It is built as a plugin-based system that can be embedded into other programs or used directly via command-line interface (CLI) for simple translation tasks. ## Key Features - **Layout Preservation**: Translates PDFs while maintaining the original document structure, including text blocks, formulas, tables, and reading order - **Bilingual Output**: Can generate both bilingual (dual) PDFs with original and translated pages side-by-side or alternating, as well as monolingual translated PDFs - **Multiple Translation Backends**: Supports any OpenAI-compatible API endpoint, including local models like Ollama, with configurable base URL, API key, and model selection - **Glossary Support**: CSV-based glossaries for consistent terminology translation, with optional target language specification per entry - **Offline Assets Management**: Generate and restore offline asset packages for air-gapped environments, with SHA3-256 hash verification - **Advanced PDF Processing**: OCR for scanned documents, automatic layout detection, formula recognition, and handling of complex elements like watermarks and decorative lines - **Plugin Architecture**: Extensible pipeline supporting custom models, OCR engines, and renderers ## Installation and Usage BabelDOC can be installed from source using `uv` and used via CLI. Basic usage example: ```bash babeldoc --openai --openai-model "gpt-4o-mini" --openai-base-url "https://api.openai.com/v1" --openai-api-key "your-api-key-here" --files example.pdf ``` Configuration can be provided via command-line options or a configuration file (TOML format). The tool supports various options for controlling translation quality, output format, page selection, watermark handling, and more. ## Python API BabelDOC provides a Python API for programmatic use, though all APIs are considered internal and direct use is not officially supported. The API is compatible with pdf2zh_next, allowing integration with existing workflows. ## Use Cases - Translating academic papers, research documents, and technical manuals - Creating bilingual versions of documents for language learning - Batch translation of PDF files with consistent terminology - Integration into document management systems or translation workflows ## Related Projects BabelDOC is part of a broader ecosystem of document processing tools, including layout readers, OCR systems, and translation services. It is designed to work with tools like PDFMathTranslate for self-deployment scenarios and integrates with Zotero plugins for research workflow automation.