PDFiumPas 文件

ObjectBounds 属性

组件: TPdf  ·  单元: PDFium
当前页面上单个页面对象的紧贴轴对齐边界矩形,表示为已应用所有 CTM 和对象自身矩阵之后的 PDF 用户空间坐标

Syntax

property ObjectBounds[Index: Integer]: TPdfRectangle; // read only

Description

The PDF content stream of a page is a sequence of page objects: text runs, vector paths, raster images, shading patterns, and embedded form XObjects (PDF 32000-1 § 8.2). ObjectBounds returns the bounding box of object number Index on the current page after PDFium has flattened the CTM stack and the object's own cm matrix, so the rectangle is directly usable for hit testing, mask building, or thumbnail crops without any further math.

The rectangle uses the standard PDF coordinate convention — origin at the lower-left corner of the page, units of 1/72 inch, Y growing upward — so Bottom < Top in a well-formed document. Wraps PDFium's FPDFPageObj_GetBounds; the call is O(1) on its own but iterates every contour vertex internally for paths, so caching the result is wise if you read it many times per object.

Valid range is 0 .. ObjectCount - 1 for the page currently selected by PageNumber. Accessing an out-of-range index returns a zero rectangle. Pair this property with ObjectType to dispatch on the kind of object before reading additional per-type properties.

Parameters

IndexZero-based page-object index, 0 ≤ Index < ObjectCount.

Remarks

Example

// Highlight every image object on the current page.
var I: Integer;
var R: TPdfRectangle;
begin
  for I := 0 to Pdf1.ObjectCount - 1 do
  if Pdf1.ObjectType[I] = otImage then
  begin
    R := Pdf1.ObjectBounds[I];
    Memo1.Lines.Add(Format('image %d: %.1f,%.1f - %.1f,%.1f (%.1fx%.1f pt)',
      [I, R.Left, R.Bottom, R.Right, R.Top,
       R.Right - R.Left, R.Top - R.Bottom]));
  end;
end;

See Also

ObjectCount, ObjectType, ObjectHandle, ObjectTransparent, PageNumber