PDFium Delphi Component Docs

TPdfWordBox record

Unit: PDFium
Stores one word, its FTextPage character range, its page-space rectangle, and its one-based page number

Syntax

type TPdfWordBox = record ... end;

Fields

FieldTypePurpose
TextWStringWord text
StartIndexIntegerZero-based FTextPage character index
CountIntegerNumber of characters in the word
RectTPdfRectanglePage-space union of the word character boxes
PageIntegerOne-based page number
CharacterIndicesTPdfIntegerArrayOptional per-unit map from UTF-16 text offset to native character index; present on native CJK word boxes, empty otherwise

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

Recognized 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, while 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

See Also

Text, SetReadingHighlight