property ObjectBounds[Index: Integer]: TPdfRectangle; // read only
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.
| Index | Zero-based page-object index, 0 ≤ Index < ObjectCount. |
// 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;