PDFium Delphi Component Docs

BuildReadingUnits function

Unit: PDFium
Converts TPdfContentFragments into sentence-level TPdfReadingUnit records without loading pdfium.dll

Syntax

function BuildReadingUnits(const Fragments: TPdfContentFragments): TPdfReadingUnits;

Parameters

FragmentsTPdfContentFragments

Return Value

TPdfReadingUnits

Description

Reading units keep headings and figure alternate text whole, split paragraph text at sentence boundaries, preserve decimal points and leave the reading cursor as a caller-owned array index

Use Rects with TPdfView.SetReadingHighlight and Language to coordinate visual highlighting with a TTS voice

Each unit also retains its handle-free SourceFragment snapshot and TextStartIndex, a zero-based UTF-16 offset after leading whitespace is trimmed; repeated identical sentences therefore retain distinct source positions

TPdfView.SelectReadingUnit resolves that logical position to native PDFium character ranges and validates the snapshot before changing the selection

Remarks

Example

Units := BuildReadingUnits(Pdf1.DocumentReadableContent);

See Also

ReadableContent, SetReadingHighlight