PDFium Delphi Component Docs

WordBoxIndexAtCharIndex 函式

單元: PDFium
把 FTextPage 字元索引對應到包含該字元的 TPdfWordBox

語法

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

參數

WordsTPdfWordBoxes
CharIndexInteger

傳回值

Integer

說明

WordBoxIndexAtCharIndex 傳回以 0 為基底的字詞方塊索引,其 StartIndex 與 Count 涵蓋請求的字元索引;若沒有符合的字詞則傳回 -1

當 TTS 游標前進時,可利用此結果選擇要反白或選取哪個 TPdfWordBox

備註

範例

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

另請參閱

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