Show / Hide Table of Contents

# Class Rect

Rect is a utility class used to manipulate PDF rectangle objects (refer to section 3.8.3 of the PDF Reference Manual).

Rect can be associated with a SDF/Cos rectangle array using Rect(Obj*) constructor or later using Rect::Attach(Obj*) or Rect::Update(Obj*) methods.

Rect keeps a local cache for rectangle points so it is necessary to call Rect::Update() method if the changes to the Rect should be saved in the attached Cos/SDF array.

##### Inheritance

object
Rect

##### Implements

IDisposable

##### Inherited Members

object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
object.ToString()

###### Namespace: pdftron.PDF

###### Assembly: PDFTronDotNet.dll

##### Syntax

    public class Rect : IDisposable

##### Remarks

Although rectangles are conventionally specified by their lower-left and upperright corners, it is acceptable to specify any two diagonally opposite corners.

### Constructors

#### Rect()

Rect default constructor.

##### Declaration

    public Rect()

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Rect(double, double, double, double)

Create a Rect and initialize it using specified parameters. The rect is not attached to any Cos/SDF object.

##### Declaration

    public Rect(double x1, double y1, double x2, double y2)

##### Parameters

Type | Name | Description
--- | --- | ---
double | x1 | x coordinate of the bottom left corner
double | y1 | y coordinate of the bottom left corner
double | x2 | x coordinate of the top right corner
double | y2 | y coordinate of the top right corner

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Rect(Obj)

Create a Rect and initialize it using given Cos/SDF rectangle Array object. The rect is attached to this object.

##### Declaration

    public Rect(Obj rect)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | rect | the rect

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

### Properties

#### x1

x coordinate of the bottom left corner

##### Declaration

    public double x1 { get; set; }

##### Property Value

Type | Description
--- | ---
double |

#### x2

x coordinate of the top right corner

##### Declaration

    public double x2 { get; set; }

##### Property Value

Type | Description
--- | ---
double |

#### y1

y coordinate of the bottom left corner

##### Declaration

    public double y1 { get; set; }

##### Property Value

Type | Description
--- | ---
double |

#### y2

y coordinate of the top right corner

##### Declaration

    public double y2 { get; set; }

##### Property Value

Type | Description
--- | ---
double |

### Methods

#### Attach(Obj)

Attach the Cos/SDF object to the Rect.

##### Declaration

    public void Attach(Obj obj)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | obj | underlying Cos/SDF object. Must be an SDF::Array with four SDF::Number elements.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Contains(double, double)

Determines if the specified point is contained within the rectangular region defined by this Rectangle.

##### Declaration

    public bool Contains(double x, double y)

##### Parameters

Type | Name | Description
--- | --- | ---
double | x | x coordinate of the specified point
double | y | y coordinate of the specified point

##### Returns

Type | Description
--- | ---
bool | true is the point is in the rectangle, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

##### Declaration

    public void Dispose()

#### Dispose(bool)

##### Declaration

    protected virtual void Dispose(bool disposing)

##### Parameters

Type | Name | Description
--- | --- | ---
bool | disposing |

#### ~Rect()

Releases all resources used by the Rect

##### Declaration

    protected ~Rect()

#### Get(double, double, double, double)

Gets the Rectangle coordinates

##### Declaration

    public void Get(double out_x1, double out_y1, double out_x2, double out_y2)

##### Parameters

Type | Name | Description
--- | --- | ---
double | out_x1 | x coordinate of the bottom left corner
double | out_y1 | y coordinate of the bottom left corner
double | out_x2 | x coordinate of the top right corner
double | out_y2 | y coordinate of the top right corner

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Height()

Gets the height.

##### Declaration

    public double Height()

##### Returns

Type | Description
--- | ---
double | rectangle's height

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Inflate(double)

Inflate.

##### Declaration

    public void Inflate(double amount)

##### Parameters

Type | Name | Description
--- | --- | ---
double | amount | amount of inflate

#### Inflate(double, double)

Inflate.

##### Declaration

    public void Inflate(double x, double y)

##### Parameters

Type | Name | Description
--- | --- | ---
double | x | the x
double | y | the y

#### IntersectRect(Rect, Rect)

Makes a Rect equal to the intersection of two existing rectangles.

##### Declaration

    public bool IntersectRect(Rect rect1, Rect rect2)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | rect1 | A Rect object that contains a source rectangle.
Rect | rect2 | A Rect object that contains a source rectangle.

##### Returns

Type | Description
--- | ---
bool | true if the intersection is not empty; 0 if the intersection is empty.

##### Remarks

The intersection is the largest rectangle contained in both existing rectangles.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Normalize()

Normalizes the rectagle to the one with lower-left and upper-right corners.

##### Declaration

    public void Normalize()

##### Remarks

Although rectangles are conventionally specified by their lower-left and upper-right corners, it is acceptable to specify any two diagonally opposite corners.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Set(double, double, double, double)

Set the coordinates of the rectangle.

##### Declaration

    public void Set(double x1, double y1, double x2, double y2)

##### Parameters

Type | Name | Description
--- | --- | ---
double | x1 | x coordinate of the bottom left corner
double | y1 | y coordinate of the bottom left corner
double | x2 | x coordinate of the top right corner
double | y2 | y coordinate of the top right corner

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Set(Rect)

Set the coordinates of the rectangle.

##### Declaration

    public void Set(Rect p)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | p | the r

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Update()

Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.

##### Declaration

    public bool Update()

##### Returns

Type | Description
--- | ---
bool | true if the attached Cos/SDF rectangle array was successfully updated, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Update(Obj)

Saves changes made to the Rect object in the attached (or specified) SDF/Cos rectangle.

##### Declaration

    public bool Update(Obj obj)

##### Parameters

Type | Name | Description
--- | --- | ---
Obj | obj | an SDF array that should be updated and attached to this Rect. If parameter rect is NULL or is omitted, update is performed on previously attached Cos/SDF rectangle.

##### Returns

Type | Description
--- | ---
bool | true if the attached Cos/SDF rectangle array was successfully updated, false otherwise.

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### Width()

Gets the width.

##### Declaration

    public double Width()

##### Returns

Type | Description
--- | ---
double | rectangle's width

##### Exceptions

Type | Condition
--- | ---
PDFNetException | PDFNetException the PDFNet exception

#### op_Assign(Rect)

Assignment operator

##### Declaration

    public Rect op_Assign(Rect rr)

##### Parameters

Type | Name | Description
--- | --- | ---
Rect | rr | a `Rect` object at the right of the operator

##### Returns

Type | Description
--- | ---
Rect | a `Rect` object equals to the given `Rect` object

### Implements

IDisposable