Skip to content

Fix PDF note reading order in the teleprompter - #17

Merged
khalidt merged 1 commit into
khalidt:mainfrom
Hoemr:teleprompter-pdf-notes
Nov 30, 2026
Merged

khalidt merged 1 commit into
khalidt:mainfrom
Hoemr:teleprompter-pdf-notes

Conversation

@Hoemr

@Hoemr Hoemr commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

Problem

The teleprompter reconstructs lines from PDFium text fragments. A fragment with different font metrics can arrive later than its neighbors, placing a middle word or punctuation at the end of the line. This affects both English and mixed Chinese–English notes. In side-by-side Beamer PDFs, PDFium can also return text from a chart form whose clip keeps it on the slide half.

Changes

  • Group fragments into rows, sort each row horizontally, and then split on wide horizontal gaps. The regression test covers a middle fragment that arrives after the ends of its line.
  • When a form's bounds cross the slide/notes divider but its clip confines it to the opposite half, exclude it from extraction for that half. The filter uses a separate page handle for the extraction.

Validation

  • cargo build --release --locked and cargo test --release --locked on macOS arm64. All 173 tests passed.
  • Tested PDF-only input in the teleprompter. A one-page English PDF with mixed fonts now reads “The result holds.” in order. A 43-page Beamer PDF preserved the order of mixed Chinese–English notes and omitted clipped chart labels on both affected pages.

@khalidt
khalidt merged commit cf4d857 into khalidt:main Nov 30, 2026
3 checks passed
@khalidt

khalidt commented Nov 30, 2026

Copy link
Copy Markdown
Owner

Thanks for fixing that! The fix has been implemented and included in the latest version.

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