PDFium Component Docs

BuildSpokenTextFromWords function

Unit: PDFium
Builds a TPdfSpokenText chunk from a contiguous TPdfWordBox range

Syntax

function BuildSpokenTextFromWords(const Words: TPdfWordBoxes; FirstWord, LastWord: Integer): TPdfSpokenText;

Parameters

WordsTPdfWordBoxes - Word boxes from a page or viewer
FirstWordInteger - First zero-based word index, clamped to 0
LastWordInteger - Last zero-based word index, clamped to High(Words)

Return Value

A TPdfSpokenText whose Text is ready for a speech engine and whose Spans map each word back to page text

Description

The helper walks the selected TPdfWordBox range and appends each word with SpokenTextAppend

The resulting span table keeps each word's page number, source character index, and source character count so a speech engine offset can be translated back to the PDF page

Remarks

Example

Words := Pdf1.PageWordBoxes;
Spoken := BuildSpokenTextFromWords(Words, 0, High(Words));

See Also

TPdf.PageWordBoxes, TPdfView.PageWordBoxes, SpokenToPageChar