PDFiumPas Docs

TryComposeReadableText

Unit: PDFium
function TryComposeReadableText(const Fragments: TPdfContentFragments;
  var Text: WString): Boolean;

Available in every edition since v3.284.0, updated 2026-11-02

Explicitly composes the supplied readable fragment stream in its supplied order. ActualText is a character substitution: adjacent ActualText sources and ordinary glyph text join without an artificial word break. Alt and E are word/phrase substitutions and require a word boundary on either side. Two ordinary glyph fragments also use a word boundary in this presentation helper

When a boundary is required, one U+0020 is inserted only if neither neighbouring edge already contains whitespace. Existing leading/trailing whitespace is preserved exactly, including adjacent spaces, tabs, line breaks, nonbreaking spaces and Unicode space separators. This helper does not infer paragraph, layout or column boundaries

An empty ActualText primary can join surrounding characters and still retain nonempty explicit alternatives. An empty word substitution retains its boundary; an empty character substitution cannot erase the boundary required by an adjacent Alt or E source

rssAlternatives groups have no automatic primary and reject composition. Choose a declaration explicitly with BuildSpokenSemanticScope. Malformed UTF-16, NUL, mismatched semantic presentation flags, non-whitespace metadata-only primaries and exhausted budgets also return False

At most 4096 fragments and 262144 output UTF-16 units are accepted, counting inserted boundary spaces. Supplementary scalars remain intact. Empty input succeeds with empty text; failure leaves the caller's Text unchanged

This pure helper neither loads PDFium nor certifies source provenance. Use BuildSpokenReadableText for current-source adjacency checks and composed native/semantic speech mappings

For complete PDF-source composition, enable IncludeEmptySemanticSources alongside semantic inclusion before collecting fragments. This preserves otherwise omitted empty or whitespace-only declarations so their character/word boundaries remain available

BuildReadingUnits and existing reading-session behaviour retain their separate per-fragment contract; composition is explicit and does not mutate the PDF or discard semantic scope alternatives

The character/word distinction follows ISO 32000-1 sections 14.9.3 through 14.9.5