PDFium Delphi Component Docs

Page object snapshots

Component: TPdf  ·  Unit: PDFium
Capture caller-owned page-object facts once for analysis, preflight, and export consumers without retaining native handles

Types

TPdfPageObjectSnapshotOptions = record ... end;

TPdfPageObjectSnapshotStatus = record ... end;

TPdfContentMarkSnapshot = record ... end;

TPdfPageObjectSnapshot = record ... end;

TPdfPageObjectsSnapshot = record ... end;

TPdfPageObjectSnapshot owns every string and dynamic array and contains no FPDF_PAGEOBJECT, FPDF_PAGEOBJECTMARK, page, font, bitmap, or text-page handle

Common facts include type, normal and RotatedBounds, matrix, active state, transparency, fill and stroke colours, alpha, stroke width, line join and HasLineJoin, line cap and HasLineCap, the dash pattern held in DashArray with its DashPhase offset, and marked-content ID

Type-specific facts include path and clip counts through PathSegmentCount, ClipPathCount, and ClipPathSegmentCount with the HasPathInfo and HasClipPath gates, optional path geometry and the ClipPath segment array, lightweight image metadata and filters through HasImageInfo, optional mark dictionaries, text through HasText, font names and flags through HasFontInfo, weight, FontSize with HasFontSize, and RenderMode with HasRenderMode

Every optional native fact has a matching Has... flag so an unavailable value remains distinct from zero or empty data

Bounded read

function ReadPageObjectsSnapshot(PageNumber: Integer; const Options: TPdfPageObjectSnapshotOptions; out Status: TPdfPageObjectSnapshotStatus): TPdfPageObjectsSnapshot;

ReadPageObjectsSnapshot walks the native page-object list under the render lock and never consults or fills the snapshot cache

PageNumber is one-based and reading another page preserves the active TPdf.PageNumber

TPdfPageObjectSnapshotOptions.Default captures common facts, path and clip counts, image metadata, and font metadata while leaving the IncludePathSegments, IncludeClipPaths, IncludeContentMarks, and IncludeText payloads disabled

TPdfPageObjectSnapshotOptions.Full enables path segments, clip paths, content marks, and object text under the same explicit budgets

Budgets cover object count through MaxObjects, MaxPathSegments, MaxClipPathSegments, MaxMarkParams, MaxTextCharacters, MaxStringBytes, and elapsed time through DeadlineMilliseconds; IncludeImageMetadata gates lightweight image facts

The status reports NativeObjectCount, ObjectsVisited, PathSegmentsVisited, ClipPathSegmentsVisited, MarksVisited, MarkParamsVisited, TextCharacters, and StringBytes, and sets ObjectLimitReached, PathSegmentLimitReached, ClipPathSegmentLimitReached, MarkParamLimitReached, TextCharacterLimitReached, StringLimitReached, or DeadlineReached when a budget truncates the result, while MetadataFailureCount reports unavailable native facts without aborting the remaining traversal

Revision-aware cache

property PageObjectsSnapshot[PageNumber: Integer]: TPdfPageObjectsSnapshot;

property PageObjectSnapshotCacheCapacity: Integer; // default 8

property PageObjectSnapshotCacheCount: Integer;

property PageObjectSnapshotCacheHitCount: Int64;

property PageObjectSnapshotCacheMissCount: Int64;

The PageObjectsSnapshot indexed property applies default options and retains only complete snapshots in a bounded least-recently-used cache

Every return value is a deep caller-owned copy, so changing nested dash arrays, mark parameters, path segments, clip paths, filters, or strings cannot modify cached data or the document

Page edits invalidate the corresponding entry, while document replacement and page-tree changes clear the complete cache

PageObjectSnapshotCacheCapacity defaults to 8, rejects negative values, and evicts the least-recently-used snapshot when a new entry would exceed it

PageObjectSnapshotCacheCount reports how many page snapshots are currently retained

PageObjectSnapshotCacheHitCount and PageObjectSnapshotCacheMissCount accumulate over the component's lifetime so callers can measure how well the capacity matches their access pattern

A capacity of zero disables retention without disabling direct bounded reads

PageComplexity reuses this cache for object types, path counts, image pixels, and transparency

Example

var
  Snapshot: TPdfPageObjectsSnapshot;
  Obj: TPdfPageObjectSnapshot;
begin
  Pdf.PageObjectSnapshotCacheCapacity := 16;
  Snapshot := Pdf.PageObjectsSnapshot[1];
  if not Snapshot.Status.Completed then
    raise Exception.Create('Page object snapshot is incomplete');

  for Obj in Snapshot.Objects do
    if Obj.ObjectType = otImage then
      IndexImage(Obj.Bounds, Obj.ImageInfo);
end;

See Also

PageObjectInfo, PathInfo, PageObjectClipPath, Text page snapshots