PDFium Delphi Component 文件

ObjectType 屬性

元件: TPdf  ·  單元: PDFium
傳回指定索引處頁面物件的類別 — 文字、路徑、影像、網底,或 form XObject。這個分類會對應到產生該物件的 PDF 內容串流運算子,讓呼叫端可以用單一 switch 分派走訪頁面物件陣列

Syntax

property ObjectType[Index: Integer]: TObjectType; // read only

Index以 0 為基底的頁面物件索引,範圍為 0 到 ObjectCount - 1

Description

ObjectType 傳回描述 Index 處頁面物件種類的 TObjectType 列舉值:

此分類結果穩定且成本低;在 ObjectCount 的 緊密迴圈中呼叫它,是在決定要叫用哪個成本較高的存取子 (ObjectBitmap、ObjectBounds、字元屬性)之前, 對頁面內容進行分類檢傷的標準做法

此屬性不會遞迴展開表單 XObject — 型別只回報 otForm, 呼叫者若需要葉層級內容,必須自行深入表單自己的物件清單

Remarks

Example

// Histogram of object types on the current page
var
  I: Integer;
  Counts: array[TObjectType] of Integer;
  T: TObjectType;
begin
  FillChar(Counts, SizeOf(Counts), 0);
  for I := 0 to Pdf.ObjectCount - 1 do
    Inc(Counts[Pdf.ObjectType[I]]);
  for T := Low(TObjectType) to High(TObjectType) do
    Memo1.Lines.Add(Format('%s: %d', [GetEnumName(TypeInfo(TObjectType), Ord(T)), Counts[T]]));
end;

See Also

ObjectCount, ObjectBounds, ObjectBitmap, RemoveObject