Projects · Document engineering
PDF Layout Translation Engine
A clean-room, geometry-first experiment for preserving readable layout when replacing live PDF text.
This project extracts the reusable engineering lessons from a much larger textbook-localization workflow without publishing any copyrighted textbook content.
It measures layout quality on synthetic fixtures before touching real documents: text-box geometry, dynamic-programming line breaking, bounded whitespace expansion, collision and overflow checks, link restoration, bookmark and page-label regression, and deterministic rendered-pixel snapshots.
Current synthetic benchmark results retain the requested font size at 1.000000 versus 0.874892 for the fixed-box baseline, with zero overflow and zero collisions in both cases. On an equal-geometry line-breaking case, raggedness improves from 0.03633852 to 0.02406803.
The engine does not translate anything. A translation system supplies replacement strings and rectangles; the engine's job is to place them without breaking the page.
The repository is deliberately benchmark-grade rather than production-grade; the next work is improving Chinese paragraph composition and visual fit quality before broadening document classes.
Provenance and license
The implementation was rewritten clean-room after read-only inspection of an internal prototype; every committed fixture is synthetic. The code is published under AGPL-3.0 because it depends on PyMuPDF, which is itself dual-licensed under the AGPL and a commercial license.