- Update pipeline to use fpdf2 renderer as default
- Remove legacy hocrtransform PDF renderer (_font.py, _hocr.py,
pdf_renderer.py)
- Update CLI and options for fpdf2 renderer
- Add fpdf2 dependency to pyproject.toml
- Update graft module for fpdf2 multi-page rendering
Comprehensive test coverage for the new hocrtransform components:
- test_ocr_element.py: Tests for BoundingBox, Baseline, FontInfo,
OcrElement dataclass methods (iter_by_class, find_by_class,
get_text_recursive, words/lines/paragraphs properties)
- test_hocr_parser.py: Tests for parsing hOCR files including
page/paragraph/line/word extraction, RTL text, rotated text,
different line types (header, caption), font info, and edge cases
- test_pdf_renderer.py: Tests for PDF rendering including text
extraction verification, page sizing, multi-line content,
text direction, baseline handling, textangle rotation, word breaks,
debug options, and image overlay
Also fixes x_font regex pattern to not capture trailing semicolons.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Split the hOCR transformation code into three distinct layers:
1. ocr_element.py - Generic OcrElement dataclass that represents OCR
output structure from any source (hOCR, ALTO, custom engines).
Includes helper classes: BoundingBox, Baseline, FontInfo.
2. hocr_parser.py - HocrParser class that parses hOCR XML files into
OcrElement trees, extracting bbox, baseline, textangle, confidence,
font info, direction, and language.
3. pdf_renderer.py - PdfTextRenderer class that renders OcrElement
trees to PDF text layers, handling text positioning, baseline
rotation, LTR/RTL, and word break injection.
The existing HocrTransform class is preserved for backward compatibility,
now delegating to the new components internally.
This separation enables:
- Support for non-hOCR OCR output formats
- Independent improvements to text rendering
- Reuse of OcrElement for other purposes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Addresses [Bug]: Crash on multiple .pdf files #1312
Not actually a fix, but at least it will get us better diagnostics. Appears old Tesseract 4.x generates bad line boxes at times.
The good: don't have to do inverse and intermediate transforms.
The bad: skew looks bad, partly because the hOCR coordinate system is inconsistent around skew?