PDFium Delphi Component Docs

DocumentReadingUnits method

Component: TPdf  ·  Unit: PDFium
Builds sentence-level TPdfReadingUnit records for the whole document readable-content stream

Syntax

function DocumentReadingUnits: TPdfReadingUnits;

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

Shared readable-content cache

TPdf.ReadableContent, ReadablePageContent, DocumentReadableContent, their reading-unit helpers and a bound TPdfView.ReadableContent share per-page managed snapshots

A hit reuses the resolved fragments, including MCID text and geometry, without rebuilding the readable MCID map or opening a native text page

The default limits are 8 pages and 8 MiB of estimated retained managed data; pages use least-recently-used eviction and also participate in the document's total CacheBudgetBytes as pckReadableContent

Each result owns its fragment array, LineRects and MarkedContentIDs; caller changes cannot modify the retained snapshot

Notified content edits, structural changes, document-language changes, deactivation and replacement clear retained data; raw native mutations require the normal UpdatePage notification

Cross-page reads use transient native handles and preserve the document page, viewer page, native focus and pending edit buffer; cache entries retain no native handles

Oversized results, disabled retention, global-budget rejection and incomplete bounded structure traversal return the current full readable result without retaining it; native read failures propagate and are not cached

Readable reads reject during an active page-object edit transaction; call after commit or rollback

Limits account for conservative managed-data charges and do not bound parser/transient allocations, returned caller copies, whole-process memory or execution time

A working set larger than the configured capacity can evict earlier pages during a document scan; cache statistics report lifetime hits, misses, evictions and bypasses, including across clears

ReadableContentCacheCapacity, ReadableContentCacheMaxBytes, ReadableContentCacheStatistics, ClearReadableContentCache

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

Remarks

Example

var Units: TPdfReadingUnits;
begin
  Units := Pdf1.DocumentReadingUnits;
  if Length(Units) > 0 then
    Memo1.Lines.Add(Units[0].Text);
end;

See Also

ReadableContent, SetReadingHighlight