PDFium Delphi Component Docs

WordBoxIndexAtCharIndex 函数

单元: PDFium
把 FTextPage 字符下标映射到包含该字符的 TPdfWordBox

语法

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

参数

WordsTPdfWordBoxes
CharIndexInteger

返回值

Integer

说明

WordBoxIndexAtCharIndex 返回其 StartIndex 和 Count 包含所请求字符索引的从 0 开始的词框索引,或在没有词匹配时返回 -1

使用结果来选择在 TTS 游标前进时应高亮或选择哪个 TPdfWordBox

备注

示例

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

参见

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