PDFiumPas Docs

Native paragraph cluster maps

Added in internal v3.400.0, updated 2026-11-10

These read-only functions in FPdfParagraphEdit join a saved cluster table to exact native character indices on the current page They require the optional source extension used by TPdf.TryGetCharacterSource The bundled Win32/Win64 ordinary and V8/XFA DLLs provide it since internal v3.401.0; native builds without these local exports return unavailable

Syntax

function ReadPdfParagraphNativeMap(Pdf:TPdf;PageObjectIndex:Integer;
  const FormPath:TPdfStyledFormPath;out Map:TPdfParagraphNativeMap):Boolean;
function ReadPdfVerticalNativeMap(Pdf:TPdf;PageObjectIndex:Integer;
  const FormPath:TPdfStyledFormPath;out Map:TPdfParagraphNativeMap):Boolean;
function PdfParagraphSelectionFromNative(const Map:TPdfParagraphNativeMap;
  FirstCharacter,CharacterCount:Integer;
  out LogicalStart,LogicalLength:Integer):Boolean;

Pass a page object index and up to 32 Form child indices, all zero-based An empty path selects a top-level object The horizontal reader selects a line Form; the vertical reader selects the first glyph of a complete shared PCM2 column Neither reader changes the document, current page or supplied path

Result

FieldMeaning
ClustersThe validated saved glyph-to-logical table, in original object/item order
CharactersMapped characters in increasing native character-index order
FormatVersionThe validated saved format, 1 for PCM1 or 2 for PCM2; zero on failure
UnmappedCharacterCountNative sources inside the selected text leaves whose declaration cannot be joined to the table

Each TPdfParagraphNativeCharacter contains CharacterIndex, GlyphIndex, LogicalStart, LogicalLength, ActualTextOffset and Kind

Generated separators, source-less characters and suppressed glyphs receive no invented native indices Only sources with a verified path into the selected leaf set can contribute to the unmapped counter A successful read can have an empty character array when native extraction supplies no joinable source

Selection and lifetime

PdfParagraphSelectionFromNative accepts an unmodified map returned by a reader and a contiguous native character-index range Every selected index must have an entry in that map, and its distinct logical clusters must form one contiguous interval It expands partial character selections to complete clusters, including both UTF-16 units of a supplementary scalar Gaps, generated or unrelated characters, partial logical overlaps and integer overflow return false with a zero logical range

Maps are snapshots of the live page and expire after edits, regeneration, page changes or reloads Read again after mutation rather than reusing old character indices An unavailable extension, invalid selection, malformed table or physical item-count mismatch returns false and clears the complete map Normal native page-loading failures can raise EPdfError

Bounds and limits

The reader retains the saved-table limit of 65534 glyphs and the 16-level descendant scan, visits at most 1048576 objects and inspects at most 262144 native characters Full native paths must fit the extension's 64-entry bound Text leaf lookup and logical offset lookup use sorted binary searches rather than geometry or a character/glyph zip

Horizontal tables need a validated logical owner; legacy PCM1 horizontal tables can use their existing owner checks PCM2 vertical association requires exact shared column membership Since internal v3.403.0, metadata-only marks may accompany the shared owner; every member must still have exactly one matching ActualText owner and exactly one matching table declaration The containing collection and its bounded descendants reject either owner reused outside the consecutive column Since internal v3.402.0, legacy vertical PCM1 also associates the original per-glyph writer profile: each declared consecutive sibling is a one-item text object with its own distinct UTF-16BE ActualText owner, only the first carries the table, and repeated logical clusters carry identical local text Complete logical coverage must be contiguous and scalar-safe; shared, missing, reused or conflicting owners are refused Other unbound legacy profiles retain the existing visual-table reader

Legacy owner blobs total at most 16 MiB, logical coverage is bounded by 8 Mi UTF-16 units, and each object has at most 64 marks The containing sibling collection is scanned for owner reuse, including descendants to depth 16, within a shared 1048576 object/mark work bound Independent Form invocations retain independent paths

Batch object edits invalidate the first-glyph PCM1 table for text replacement, removal, insertion admitted by the selected boundary affinity, or an overlapping reviewed ActualText revision anywhere in the declared column Property-only edits, unaffected neighboring columns and independent invocations retain their tables If the optional raw-item query is unavailable, the invalidator conservatively treats a single-object PCM1 declaration as covering its bounded declared sibling count

Internal v3.403.0 also invalidates affected tables after direct TPdf text/member/ActualText edits Property-only updates preserve metadata and regenerate complete represented mark scopes The bundled native generator preserves shared declaration prefixes across adjacent nonempty content streams and publishes complex detached parameters through new Properties resources Native builds without parameter detachment refuse a table-affecting logical edit before mutation Empty/gapped streams, unpainted semantic events and arbitrary raw-native rewrites remain separate source-preservation gates

The appended FormatVersion field makes the Win32 map record 16 bytes; Win64 stays 24 bytes Rebuild C++ consumers against the updated headers

The association reports the logical spans declared by the saved metadata Length, digest, owner and item-count checks detect specific stale or malformed inputs; they do not authenticate arbitrary external glyph-stream, font-program or ToUnicode changes The candidate does not add ActualText inherited only from an outer Form to PDFium's native extraction model

The original map implementation was qualified against the Win64 ordinary prototype with 730 focused assertions Internal v3.401.0 delivers the extension on all four bundled Windows DLL profiles, with 338 focused API, ABI, crypto and XFA compatibility checks recorded in Tests/AcceptanceReports/native-text-source-delivery-3.401.0-20261110.json Those delivery checks retain their own exact scope and do not relabel the earlier 730 assertions as a rerun on the new binaries Internal v3.402.0 retains 273 legacy persistence assertions and 36 malformed/supplementary assertions from before the separate batch-invalidation addition, plus 54 focused edit assertions on the completed implementation; one Win32 C++ compile checks the appended field layout The exact run identities and scope are recorded in Tests/AcceptanceReports/legacy-native-clusters-3.402.0-20261110.json Arbitrary source/legacy profiles and complete supported edit/regeneration coverage remain CE-04-C5 work