Skip to content

feat: experimental ocr with paragraph regrouping and adaptive typesetting - #1185

Merged
reycn merged 3 commits into
mainfrom
codex/experimental-ocr
Sep 8, 2026
Merged

reycn merged 3 commits into
mainfrom
codex/experimental-ocr

Conversation

@reycn

@reycn reycn commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

Adds experimental OCR support to fast mode so image-only PDF pages can be translated without preprocessing them in another tool. PyMuPDF supplies the local OCR engine; the new [ocr] extra downloads and caches Tesseract language data on first use, with language and local-data overrides available.

Recognized words are regrouped within detected layout regions before translation, joining wrapped lines and soft hyphens. Translated paragraphs start at the median source font size and shrink to fit their original bounds. Detected figures, tables, and standalone formulas are preserved, and bilingual output retains the original source pages.

This initial implementation targets white-background, image-only scans. Pages with existing text or OCR layers are skipped; handwriting and inline equations may be recognized incorrectly. Precise mode is unchanged.

Validation: 70 OCR, converter, layout, and kernel regression tests passed before the final documentation change. Includes coverage for cached downloads, page selection, source preservation, two-column grouping, and bounded typesetting. A live external Chinese translation preview was not completed.

Co-authored-by: reycn <11225092+reycn@users.noreply.github.com>
@reycn
reycn merged commit 8c34c76 into main Sep 8, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants