PDFium Delphi Component Docs

PageWordBoxes method

Component: TPdfView  ·  Unit: PDFium
Returns TPdfWordBox records for words on the current TPdfView page with character ranges and page-space rectangles

Syntax

function PageWordBoxes: TPdfWordBoxes;

Return Value

TPdfWordBoxes

Description

Word boxes split page text on whitespace, tabs, line breaks and NBSP characters

The component methods also union FPDFText_GetCharBox rectangles into one page-space TPdfRectangle for each word

WordSegmentation defaults to wsmWhitespace, preserving the original space/tab/newline/NBSP tokenizer

Explicit wsmCjk provides deterministic tailored units: individual Han scalars, Hiragana runs, Katakana runs, Hangul runs, separate punctuation and script transitions, including fullwidth forms and Unicode whitespace

Recognised combining accents, voiced marks and variation selectors remain with the preceding unit; valid surrogate pairs are never split

This profile provides useful navigation units without a dictionary and is not linguistic Chinese/Japanese word recognition or full Unicode boundary-conformance; see Unicode text segmentation for the distinction between default boundaries and language-specific tailoring

Document, viewer and session modes are independent; change the applicable host before extracting or playing words

Viewer changes clear tracked/prefetched word geometry and the active cursor; session changes stop playback so the next chunk uses the selected mode

Native CJK word boxes include CharacterIndices, mapping each UTF-16 text unit to its native character index; StartIndex and Count remain native ranges, whilst pure BuildWordBoxes uses UTF-16 ranges

BuildSpokenTextFromWords preserves adjacent source units without inserting artificial spaces and emits exact source mappings from CharacterIndices; invalid explicit maps raise EPdfError

Remarks

Example

var Words: TPdfWordBoxes;
  Rects: TPdfRectangles;
begin
  Words := PdfView1.PageWordBoxes;
  if Length(Words) > 0 then
  begin
    SetLength(Rects, 1);
    Rects[0] := Words[0].Rect;
    PdfView1.SetReadingHighlight(Rects, Words[0].Page);
  end;
end;

See Also

Text, SetReadingHighlight