PDFium Delphi Component Docs

SelectReadingUnit method

Unit: PDFium

Selects a sentence-level reading unit through its validated source-fragment snapshot and logical UTF-16 offset

Syntax

function SelectReadingUnit(const ReadingUnit: TPdfReadingUnit): Boolean;

Description

Pass a unit produced by BuildReadingUnits, TPdf.ReadingUnits, TPdf.DocumentReadingUnits or TPdfView.ReadingUnits

SourceFragment carries the handle-free source snapshot and TextStartIndex records the zero-based UTF-16 position of the trimmed sentence inside that fragment; these are distinct from native PDFium character indexes

The method validates the canonical sentence, resolves its logical characters to native characters and only replaces the selection where the complete mapping succeeds

Repeated identical sentences and document-wide FragmentIndex values remain distinguishable through the retained source snapshot and sentence offset

See Also

SelectFragment, SelectReadingUnit, TPdfReadingUnit, SelectionMode

TPdf.ParagraphContinuation is disabled by default and affects DocumentReadableContent and DocumentReadingUnits only; page-readable snapshots remain unchanged and reusable

When enabled, the last ordinary paragraph/plain fragment of one page may join the first on the next page if both lie in the configured unrotated CropBox edge bands, align horizontally, use compatible line heights, share language and lack table/list context

A terminal sentence boundary, uppercase/noncontinuing start, heading, table, list, blank page, geometry/language mismatch or exhausted budget keeps the original fragments separate

EdgeBand defaults to 72 points, AlignmentTolerance to 18, MaxParts to 16 and MaxJoinedTextUnits to 262144; numeric settings are validated before assignment and part limits accept 1..64

Adjacent CJK parts remain unspaced; retained end-of-line hyphens join without an artificial space and optional Dehyphenate removes the boundary hyphen from reader text only

Every joined fragment has SourceParts containing each original page, complete source text, source UTF-16 slice, combined-text offset, MCIDs and original page-space geometry

Fragment/reading-unit Page and primary geometry identify the first source page; other pages remain available in SourceParts, and selection/speech helpers resolve their actual native positions without navigating the viewer

SelectFragment, SelectReadingUnit and BuildSpokenReadingUnit validate every selected source slice and can select/map a sentence spanning multiple pages or a later sentence on only one source page

Inserted join spaces are ContextOnly spans with no native character; source text, source ranges and part arrays remain independent snapshots and rejection preserves selection or caller speech output

Joining permits up to 1048576 total raw source UTF-16 units and 4096 MCIDs/rectangles per part; exact mapping shares the 4194304 native-character visit budget across selected parts

This is conservative paragraph continuation, not universal paragraph recognition; it does not mutate saved PDFs, remove physical hyphens or automatically change the visible page

Opt-in IncludeFormXObjects expands unique untagged nested Forms with page-space geometry and native selection/speech ownership; NativeObjectPath and FormSourceIdentity are independently copied into fragments, reading units and continuation source parts

NestedFormsComplete=False and NestedFormsError report disabled shared/tagged, clipped, unsupported or over-budget paths; unrelated top-level output and supported siblings remain available

Set IncludeSharedFormXObjects together with IncludeFormXObjects to read each untagged shared invocation separately, including identical overlapping text; source identities bind the live invocation and full object path

Separate opt-in IncludeTaggedFormXObjects reads the bounded tagged Form profile in certified structure order, with explicit page/Form MCID namespaces and ParentTree ownership; same-page shared invocations also require IncludeSharedFormXObjects, and certified fragments carry independent live paths/identities and StructElementIndex=-1