wxyhgk/retain-pdf
About
Translate PDFs while preserving their layout, formulas, and structure, for research and technical documents.
Productivity & AutomationMeasured star growth
- in 24h
- +6
- in 7 days
- +15
- in 15 days
- +47
- in 1 month
- +95
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.en.md
OriginalRetainPDF: Layout-Preserving PDF Translation
中文 · English · Tiếng Việt
RetainPDF is currently the only open-source project built for layout-preserving translation of image-based and scanned PDFs, with translation and typesetting quality that matches or even surpasses comparable commercial products.
Its in-house typography algorithm restores complex formulas and multi-column paper layouts. Scanned PDF translation, PDF structure optimization, code protection, custom translation strategies, and an open API are all included.
The translation system is also built in-house, with dedicated handling for cross-column and cross-page passages, broken sentences, and continued paragraphs. It restores complete semantic units before translation instead of translating isolated OCR boxes and losing context.
You can also choose Agent translation: it reads the whole book first to fix terms and style, then translates page by page and reviews every paragraph, so each term has one translation across the book. Use it for books you will read closely.
Inline formulas are RetainPDF's defining advantage: formulas, surrounding text, and inline layout remain stable after translation—something other open-source PDF translators do not currently achieve.
The code, API, and deployment stack are fully open, with support for self-hosting and further development.
Core capability comparison:
| Project | Scanned PDFs | Complex inline formulas | Protect code from translation | Table control | Custom translation strategy | Layout preservation | PDF size optimization | API automation |
|---|---|---|---|---|---|---|---|---|
| PDFMathTranslate | ❌ | ❌ | ❌ | Limited | Limited | Average | Average | ✅ |
| PolyglotPDF | ❌ | ❌ | ❌ | Limited | Limited | Average | Average | ✅ |
| Doc2X | ✅ | ✅ | ❌ | Moderate | Limited | Strong | Limited | ❌ Not public |
| RetainPDF | ✅ | ✅ Strong preservation | ✅ | ✅ Optional | ✅ Rule-based | Strong | ✅ Continuously improved | ✅ |
Product
Library
Manage papers, books, and scanned documents in one library, with translation status, collections, and favorites.
Side-by-side reading
Compare the source and translated PDFs on the same page to verify formulas, figures, citations, and layout.
Markdown reading
Read PDF and Markdown side by side while preserving formulas and images.
Translation examples
Source-to-translation examples for scientific papers, scanned PDFs, formula-heavy documents, and books:
Row 1: scientific papers · Row 2: scanned and formula-heavy documents · Row 3: books and textbooks
Quick start
Desktop
Download the appropriate package from GitHub Releases:
- Windows:
Setup.exe(on “Windows protected your PC”, click “More info” → “Run anyway”) - macOS:
.dmg(Apple silicon, signed and notarized) - Linux:
.deb(sudo apt install ./RetainPDF-Linux-<version>.deb)
On first launch the app asks for your OCR and translation keys; step by step: user guide (Chinese).
Docker
git clone https://github.com/wxyhgk/retain-pdf.git
cd retain-pdf/ops/deployment/docker/delivery
docker compose up -d
Open http://127.0.0.1:40001. To update:
docker compose pull
docker compose up -d
See the Docker deployment guide for more options.
Community
QQ group: 1101779791
Development
See the contribution guide, project documentation, and backend guide.
License
This project is distributed under the MIT License. See LICENSE for the full text.
Explore related projects
Loading…