PDFium Delphi Component 文件

ObjectType 属性

组件: TPdf  ·  单元: PDFium
返回指定索引处页面对象的类别——文本、路径、图像、渐变或表单 XObject。该分类与生成对象的 PDF 内容流操作符一致,便于调用方用一次 switch 分派遍历页面对象数组

Syntax

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

Index基于 0 的页面对象索引,范围为 0 到 ObjectCount - 1

Description

ObjectType 返回一个描述 Index 处页面对象种类的 TObjectType 枚举值:

该分类稳定且廉价;在遍历 ObjectCount 的紧密循环中调用它是决定调用哪个更昂贵访问器(ObjectBitmap、 ObjectBounds、字符属性)之前分诊页面 内容的标准方式

此属性不递归展开 form XObject — 类型 报告 otForm,如果调用方需要叶级内容,必须向下进入 form 自身的对象列表

Remarks

Example

// 当前页面上对象类型的直方图
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