TPdfSpokenText chunk from a contiguous TPdfWordBox rangefunction BuildSpokenTextFromWords(const Words: TPdfWordBoxes; FirstWord, LastWord: Integer): TPdfSpokenText;
| Words | TPdfWordBoxes - Word boxes from a page or viewer |
| FirstWord | Integer - First zero-based word index, clamped to 0 |
| LastWord | Integer - Last zero-based word index, clamped to High(Words) |
TPdfSpokenText whose Text is ready for a speech engine and whose Spans map each word back to page textThe helper walks the selected TPdfWordBox range and appends each word with SpokenTextAppend
The resulting span table keeps each word's page number, source character index, and source character count so a speech engine offset can be translated back to the PDF page
SpokenToPageChar or TPdfReadingSession.FeedSpokenPosition to drive word-level highlighting from the spoken offsetWords := Pdf1.PageWordBoxes;
Spoken := BuildSpokenTextFromWords(Words, 0, High(Words));