PDFium Component Docs

WordBoxIndexAtCharIndex function

Unit: PDFium
Maps an FTextPage character index to the TPdfWordBox that contains it

Syntax

function WordBoxIndexAtCharIndex(const Words: TPdfWordBoxes; CharIndex: Integer): Integer;

Parameters

WordsTPdfWordBoxes
CharIndexInteger

Return Value

Integer

Description

WordBoxIndexAtCharIndex returns the zero-based word-box index whose StartIndex and Count contain the requested character index, or -1 when no word matches

Use the result to choose which TPdfWordBox should be highlighted or selected as a TTS cursor advances

Remarks

Example

Index := WordBoxIndexAtCharIndex(Words, PdfView1.CurrentCharIndex);
if Index >= 0 then
  PdfView1.SelectWordBox(Words[Index]);

See Also

BuildWordBoxes, TPdfView.PageWordBoxes, TPdfView.SelectWordBox, TPdfView.SetReadingHighlight