Table of Contents

Class Rectangle

Namespace
iText.Kernel.Geom
Assembly
itext.kernel.dll

Class that represent rectangle object.

public class Rectangle
Inheritance
Rectangle
Derived
Inherited Members

Constructors

Rectangle(float, float)

Creates new instance of rectangle with (0, 0) as the lower left point.

public Rectangle(float width, float height)

Parameters

width float

the width value

height float

the height value

Rectangle(float, float, float, float)

Creates new instance.

public Rectangle(float x, float y, float width, float height)

Parameters

x float

the x coordinate of lower left point

y float

the y coordinate of lower left point

width float

the width value

height float

the height value

Rectangle(Rectangle)

Creates the copy of given Rectangle

public Rectangle(Rectangle rect)

Parameters

rect Rectangle

the copied Rectangle

Fields

height

protected float height

Field Value

float

width

protected float width

Field Value

float

x

protected float x

Field Value

float

y

protected float y

Field Value

float

Methods

ApplyMargins(float, float, float, float, bool)

Change the rectangle according the specified margins.

public virtual Rectangle ApplyMargins(float topIndent, float rightIndent, float bottomIndent, float leftIndent, bool reverse)

Parameters

topIndent float

the value on which the top y coordinate will change.

rightIndent float

the value on which the right x coordinate will change.

bottomIndent float

the value on which the bottom y coordinate will change.

leftIndent float

the value on which the left x coordinate will change.

reverse bool

if true the rectangle will expand, otherwise it will shrink

Returns

Rectangle

the rectangle with applied margins

CalculateBBox(IList<Point>)

Calculates the bounding box of passed points.

public static Rectangle CalculateBBox(IList<Point> points)

Parameters

points IList<Point>

the points which appear inside the area

Returns

Rectangle

the bounding box of passed points.

Clone()

Creates a "deep copy" of this rectangle, meaning the object returned by this method will be independent of the object being cloned.

public virtual Rectangle Clone()

Returns

Rectangle

the copied rectangle.

Contains(Rectangle)

Check if this rectangle contains the passed rectangle.

public virtual bool Contains(Rectangle rect)

Parameters

rect Rectangle

a rectangle which is to be checked if it is fully contained inside this rectangle.

Returns

bool

true if this rectangle contains the passed rectangle, false otherwise.

Remarks

Check if this rectangle contains the passed rectangle. A rectangle will envelop itself, meaning that for any rectangle rect the expression rect.contains(rect) always returns true.

CreateBoundingRectangleFromQuadPoint(PdfArray)

Create the bounding rectangle for the given array of quadpoints.

public static Rectangle CreateBoundingRectangleFromQuadPoint(PdfArray quadPoints)

Parameters

quadPoints PdfArray

an array containing 8 numbers that correspond to 4 points.

Returns

Rectangle

The smallest orthogonal rectangle containing the quadpoints.

CreateBoundingRectanglesFromQuadPoint(PdfArray)

Create a list of bounding rectangles from an 8 x n array of Quadpoints.

public static IList<Rectangle> CreateBoundingRectanglesFromQuadPoint(PdfArray quadPoints)

Parameters

quadPoints PdfArray

8xn array of numbers representing 4 points

Returns

IList<Rectangle>

a list of bounding rectangles for the passed quadpoints

DecreaseHeight(float)

Decreases the height of rectangle by the given value.

public virtual Rectangle DecreaseHeight(float extra)

Parameters

extra float

the value of the extra height to be subtracted.

Returns

Rectangle

this Rectangle instance.

Remarks

Decreases the height of rectangle by the given value. May be used in chain.

DecreaseWidth(float)

Decreases the width of rectangle by the given value.

public virtual Rectangle DecreaseWidth(float extra)

Parameters

extra float

the value of the extra width to be subtracted.

Returns

Rectangle

this Rectangle instance.

Remarks

Decreases the width of rectangle by the given value. May be used in chain.

EqualsWithEpsilon(Rectangle)

Compares instance of this rectangle with given deviation equals to 0.0001

public virtual bool EqualsWithEpsilon(Rectangle that)

Parameters

that Rectangle

the Rectangle to compare with.

Returns

bool

true if the difference between corresponding rectangle values is less than deviation and false otherwise.

EqualsWithEpsilon(Rectangle, float)

Compares instance of this rectangle with given deviation.

public virtual bool EqualsWithEpsilon(Rectangle that, float eps)

Parameters

that Rectangle

the Rectangle to compare with.

eps float

the deviation value.

Returns

bool

true if the difference between corresponding rectangle values is less than deviation and false otherwise.

GetBottom()

Gets the Y coordinate of the lower edge of the rectangle.

public virtual float GetBottom()

Returns

float

the Y coordinate of the lower edge of the rectangle.

Remarks

Gets the Y coordinate of the lower edge of the rectangle. Same as: getY().

GetCommonRectangle(params Rectangle[])

Calculates the common rectangle which includes all the input rectangles.

public static Rectangle GetCommonRectangle(params Rectangle[] rectangles)

Parameters

rectangles Rectangle[]

list of input rectangles.

Returns

Rectangle

common rectangle.

GetHeight()

Gets the height of rectangle.

public virtual float GetHeight()

Returns

float

the height of rectangle.

GetIntersection(Rectangle)

Get the rectangle representation of the intersection between this rectangle and the passed rectangle

public virtual Rectangle GetIntersection(Rectangle rect)

Parameters

rect Rectangle

the rectangle to find the intersection with

Returns

Rectangle

the intersection rectangle if the passed rectangles intersects with this rectangle, a rectangle representing a line if the intersection is along an edge or a rectangle representing a point if the intersection is a single point, null otherwise

GetLeft()

Gets the X coordinate of the left edge of the rectangle.

public virtual float GetLeft()

Returns

float

the X coordinate of the left edge of the rectangle.

Remarks

Gets the X coordinate of the left edge of the rectangle. Same as: getX().

GetRectangleOnRotatedPage(Rectangle, PdfPage)

Gets the rectangle as it looks on the rotated page and returns the rectangle in coordinates relevant to the true page origin.

public static Rectangle GetRectangleOnRotatedPage(Rectangle rect, PdfPage page)

Parameters

rect Rectangle

the rectangle as it looks on the rotated page.

page PdfPage

the page on which one want to process the rectangle.

Returns

Rectangle

the newly created rectangle with translated coordinates.

Remarks

Gets the rectangle as it looks on the rotated page and returns the rectangle in coordinates relevant to the true page origin. This rectangle can be used to add annotations, fields, and other objects to the rotated page.

GetRight()

Gets the X coordinate of the right edge of the rectangle.

public virtual float GetRight()

Returns

float

the X coordinate of the right edge of the rectangle.

Remarks

Gets the X coordinate of the right edge of the rectangle. Same as: getX() + getWidth().

GetTop()

Gets the Y coordinate of the upper edge of the rectangle.

public virtual float GetTop()

Returns

float

the Y coordinate of the upper edge of the rectangle.

Remarks

Gets the Y coordinate of the upper edge of the rectangle. Same as: getY() + getHeight().

GetWidth()

Gets the width of rectangle.

public virtual float GetWidth()

Returns

float

the width of rectangle.

GetX()

Gets the X coordinate of lower left point.

public virtual float GetX()

Returns

float

the X coordinate of lower left point.

GetY()

Gets the Y coordinate of lower left point.

public virtual float GetY()

Returns

float

the Y coordinate of lower left point.

IncreaseHeight(float)

Increases the height of rectangle by the given value.

public virtual Rectangle IncreaseHeight(float extra)

Parameters

extra float

the value of the extra height to be added.

Returns

Rectangle

this Rectangle instance.

Remarks

Increases the height of rectangle by the given value. May be used in chain.

IncreaseWidth(float)

Increases the width of rectangle by the given value.

public virtual Rectangle IncreaseWidth(float extra)

Parameters

extra float

the value of the extra wudth to be added.

Returns

Rectangle

this Rectangle instance.

Remarks

Increases the width of rectangle by the given value. May be used in chain.

IntersectsLine(float, float, float, float)

Checks if rectangle have common points with line, specified by two points.

public virtual bool IntersectsLine(float x1, float y1, float x2, float y2)

Parameters

x1 float

the x coordinate of first line's point.

y1 float

the y coordinate of first line's point.

x2 float

the x coordinate of second line's point.

y2 float

the y coordinate of second line's point.

Returns

bool

true if rectangle have common points with line and false otherwise.

MoveDown(float)

Decreases the y coordinate.

public virtual Rectangle MoveDown(float move)

Parameters

move float

the value on which the position will be changed.

Returns

Rectangle

this Rectangle instance.

MoveLeft(float)

Decreases the x coordinate.

public virtual Rectangle MoveLeft(float move)

Parameters

move float

the value on which the position will be changed.

Returns

Rectangle

this Rectangle instance.

MoveRight(float)

Increases the x coordinate.

public virtual Rectangle MoveRight(float move)

Parameters

move float

the value on which the position will be changed.

Returns

Rectangle

this Rectangle instance.

MoveUp(float)

Increases the y coordinate.

public virtual Rectangle MoveUp(float move)

Parameters

move float

the value on which the position will be changed.

Returns

Rectangle

this Rectangle instance.

Overlaps(Rectangle)

Check if this rectangle and the passed rectangle overlap

public virtual bool Overlaps(Rectangle rect)

Parameters

rect Rectangle

a rectangle which is to be checked if it overlaps the passed rectangle

Returns

bool

true if there is overlap of some kind

Overlaps(Rectangle, float)

Check if this rectangle and the passed rectangle overlap

public virtual bool Overlaps(Rectangle rect, float epsilon)

Parameters

rect Rectangle

a rectangle which is to be checked if it overlaps the passed rectangle

epsilon float

if greater than zero, then this is the maximum distance that one rectangle can go to another, but they will not overlap, if less than zero, then this is the minimum required distance between the rectangles so that they do not overlap

Returns

bool

true if there is overlap of some kind

SetBbox(float, float, float, float)

Sets the rectangle by the coordinates, specifying its lower left and upper right points.

public virtual Rectangle SetBbox(float llx, float lly, float urx, float ury)

Parameters

llx float

the X coordinate of lower left point

lly float

the Y coordinate of lower left point

urx float

the X coordinate of upper right point

ury float

the Y coordinate of upper right point

Returns

Rectangle

this Rectangle instance.

Remarks

Sets the rectangle by the coordinates, specifying its lower left and upper right points. May be used in chain.

Note: this method will normalize coordinates, so the rectangle will have non negative width and height, and its x and y coordinates specified lower left point.

SetHeight(float)

Sets the height of rectangle.

public virtual Rectangle SetHeight(float height)

Parameters

height float

the the width of rectangle to be set.

Returns

Rectangle

this Rectangle instance.

Remarks

Sets the height of rectangle. May be used in chain.

SetWidth(float)

Sets the width of rectangle.

public virtual Rectangle SetWidth(float width)

Parameters

width float

the the width of rectangle to be set.

Returns

Rectangle

this Rectangle instance.

Remarks

Sets the width of rectangle. May be used in chain.

SetX(float)

Sets the X coordinate of lower left point.

public virtual Rectangle SetX(float x)

Parameters

x float

the X coordinate of lower left point to be set.

Returns

Rectangle

this Rectangle instance.

Remarks

Sets the X coordinate of lower left point. May be used in chain.

SetY(float)

Sets the Y coordinate of lower left point.

public virtual Rectangle SetY(float y)

Parameters

y float

the Y coordinate of lower left point to be set.

Returns

Rectangle

this Rectangle instance.

Remarks

Sets the Y coordinate of lower left point. May be used in chain.

ToPointsArray()

Convert rectangle to an array of points

public virtual Point[] ToPointsArray()

Returns

Point[]

array of four extreme points of rectangle

ToString()

Gets the string representation of rectangle.

public override string ToString()

Returns

string

the string representation of rectangle.