Rectangle class

Rectangle class

Describes a rectangular area on a page or image, for example an OCR text bounds or a redaction box.

The Rectangle type exposes the following members:

Constructors

Constructor Description
init Initializes a rectangle from corner coordinates and dimensions.
init Initializes a rectangle from a top-left point and region size.

Methods

Method Description
equals Compares the bounds with another rectangle.
equals Compares this rectangle with another object.
get_hash_code Returns a hash code derived from position and size.
to_string Returns the bounds in a readable form.

Properties

Property Description
height The height of the area, in pixels.
is_empty The rectangle is empty.
location The top-left corner of the rectangle.
size The width and height of the rectangle.
width The width of the area, in pixels.
x The horizontal position of the top-left corner, in pixels.
y The vertical position of the top-left corner, in pixels.

Fields

Field Description
EMPTY A rectangle with zero width and height at the origin.

Example

from groupdocs.redaction.options.drawing import Rectangle

# Define a rectangle at position (40, 40) with size 120x40
rect = Rectangle(40, 40, 120, 40)
print(rect)

Guides

Task guides that use Rectangle:

See Also