TPdfPageObjectSnapshotOptions = record ... end;
TPdfPageObjectSnapshotStatus = record ... end;
TPdfContentMarkSnapshot = record ... end;
TPdfPageObjectSnapshot = record ... end;
TPdfPageObjectsSnapshot = record ... end;
TPdfPageObjectSnapshot은 모든 문자열과 동적 배열을 직접 소유하며 FPDF_PAGEOBJECT, FPDF_PAGEOBJECTMARK, 페이지, 폰트, 비트맵, 텍스트 페이지 핸들을 전혀 담지 않습니다
공통 정보에는 타입, 일반 및 RotatedBounds, 행렬, 활성 상태, 투명도, 채우기 및 선 색상, 알파, 선 두께, HasLineJoin이 있는 line join, HasLineCap이 있는 line cap, DashArray에 담기고 DashPhase로 오프셋되는 대시 패턴, 마킹된 콘텐츠 ID가 있습니다
타입별 정보에는 HasPathInfo와 HasClipPath 게이트 뒤의 PathSegmentCount, ClipPathCount, ClipPathSegmentCount를 통한 경로 및 클립 개수, 선택적 경로 기하 정보와 ClipPath 세그먼트 배열, HasImageInfo를 통한 가벼운 이미지 메타데이터와 필터, 선택적 마크 딕셔너리, HasText를 통한 텍스트, HasFontInfo를 통한 폰트 이름과 플래그, weight, HasFontSize가 있는 FontSize, HasRenderMode가 있는 RenderMode가 있습니다
선택적 네이티브 정보마다 대응하는 Has... 플래그가 있어서 사용할 수 없는 값이 0이나 빈 데이터와 구별됩니다
function ReadPageObjectsSnapshot(PageNumber: Integer; const Options: TPdfPageObjectSnapshotOptions; out Status: TPdfPageObjectSnapshotStatus): TPdfPageObjectsSnapshot;
ReadPageObjectsSnapshot은 render lock 아래에서 네이티브 페이지 객체 목록을 순회하며 스냅샷 캐시를 참조하거나 채우지 않습니다
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은 기본 옵션을 적용하고 완전한 스냅샷만 크기가 제한된 LRU 캐시에 보관합니다
반환값은 모두 호출자 소유의 깊은 복사본이므로 중첩된 대시 배열, 마크 파라미터, 경로 세그먼트, 클립 경로, 필터, 문자열을 바꿔도 캐시된 데이터나 문서는 수정되지 않습니다
페이지 편집은 해당 항목을 무효화하고, 문서 교체와 페이지 트리 변경은 캐시 전체를 지웁니다
PageObjectSnapshotCacheCapacity의 기본값은 8이며 음수를 거부하고, 새 항목이 용량을 넘으면 최근사용 캐시에서 가장 오래된 스냅샷을 축출합니다
PageObjectSnapshotCacheCount는 현재 유지 중인 페이지 스냅샷 수를 보고합니다
PageObjectSnapshotCacheHitCount와 PageObjectSnapshotCacheMissCount는 구성 요소 수명 동안 누적되므로 호출자는 용량이 접근 패턴에 얼마나 맞는지 측정할 수 있습니다
용량 0은 직접적인 한도 있는 읽기를 막지 않으면서 보관만 비활성화합니다
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;