TPdfPageObjectSnapshotOptions = record ... end;
TPdfPageObjectSnapshotStatus = record ... end;
TPdfContentMarkSnapshot = record ... end;
TPdfPageObjectSnapshot = record ... end;
TPdfPageObjectsSnapshot = record ... end;
TPdfPageObjectSnapshot 拥有自己的全部字符串和动态数组,不包含 FPDF_PAGEOBJECT、FPDF_PAGEOBJECTMARK、页面、字体、位图或文本页句柄
通用事实包括类型、常规与 RotatedBounds、矩阵、活动状态、透明度、填充色与描边色、alpha、描边宽度、线连接与 HasLineJoin、线帽与 HasLineCap、保存在 DashArray 中并带 DashPhase 偏移的虚线图案,以及标记内容 ID
类型特定事实包括通过 PathSegmentCount、ClipPathCount 和 ClipPathSegmentCount 并由 HasPathInfo 与 HasClipPath 门控的路径与剪裁计数、可选的路径几何与 ClipPath 线段数组、通过 HasImageInfo 提供的轻量图像元数据与滤镜、可选的标记字典、通过 HasText 提供的文本、通过 HasFontInfo 提供的字体名称与标志、字重、带 HasFontSize 的 FontSize 以及带 HasRenderMode 的 RenderMode
每个可选的原生事实都有对应的 Has... 标志,使不可用的值与零或空数据保持区分
function ReadPageObjectsSnapshot(PageNumber: Integer; const Options: TPdfPageObjectSnapshotOptions; out Status: TPdfPageObjectSnapshotStatus): TPdfPageObjectsSnapshot;
ReadPageObjectsSnapshot 在渲染锁下遍历原生页面对象列表,既不查询也不填充快照缓存
PageNumber 从 1 开始计数,读取其他页面会保持活动的 TPdf.PageNumber 不变
TPdfPageObjectSnapshotOptions.Default 捕获通用事实、路径与剪裁计数、图像元数据和字体元数据,同时保持 IncludePathSegments、IncludeClipPaths、IncludeContentMarks 和 IncludeText 载荷处于禁用状态
TPdfPageObjectSnapshotOptions.Full 在相同的显式预算下启用路径线段、剪裁路径、内容标记和对象文本
预算涵盖对象数量(MaxObjects)、MaxPathSegments、MaxClipPathSegments、MaxMarkParams、MaxTextCharacters、MaxStringBytes 以及经过时间(DeadlineMilliseconds);IncludeImageMetadata 门控轻量图像事实
状态会报告 NativeObjectCount、ObjectsVisited、PathSegmentsVisited、ClipPathSegmentsVisited、MarksVisited、MarkParamsVisited、TextCharacters 和 StringBytes,并在预算截断结果时设置 ObjectLimitReached、PathSegmentLimitReached、ClipPathSegmentLimitReached、MarkParamLimitReached、TextCharacterLimitReached、StringLimitReached 或 DeadlineReached,而 MetadataFailureCount 报告不可用的原生事实而不中断其余遍历
property PageObjectsSnapshot[PageNumber: Integer]: TPdfPageObjectsSnapshot;
property PageObjectSnapshotCacheCapacity: Integer; // default 8
property PageObjectSnapshotCacheCount: Integer;
property PageObjectSnapshotCacheHitCount: Int64;
property PageObjectSnapshotCacheMissCount: Int64;
PageObjectsSnapshot 索引属性应用默认选项,并仅在有界的最近最少使用缓存中保留完整的快照
每个返回值都是归调用方所有的深拷贝,因此修改嵌套的虚线数组、标记参数、路径线段、剪裁路径、滤镜或字符串都无法更改缓存数据或文档
页面编辑会使对应条目失效,而文档替换和页面树更改会清空整个缓存
PageObjectSnapshotCacheCapacity 默认为 8,拒绝负值,当新条目将超出容量时淘汰最近最少使用的快照
PageObjectSnapshotCacheCount 报告当前保留的页面快照数量
PageObjectSnapshotCacheHitCount 和 PageObjectSnapshotCacheMissCount 在组件生命周期内累计,调用方可以借此衡量容量与访问模式的匹配程度
容量为零会禁用保留,但不禁用直接有界读取
PageComplexity 在对象类型、路径计数、图像像素和透明度方面复用此缓存
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;