Opait PDF Library
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Properties | List of all members
Opait.Pdf.Api.PdfRectangle Class Reference

Class represents a rectangular region in PDF world coordinates. The rectangle is kept normalized. More...

Inheritance diagram for Opait.Pdf.Api.PdfRectangle:

Public Member Functions

 PdfRectangle ()
 Initializes a new instance of the PdfRectangle class.
 
 PdfRectangle (double left, double top, double right, double bottom)
 Initializes a new instance of the PdfRectangle class with specified coordinates. More...
 
 PdfRectangle (XElement xml, int scale)
 Initializes a new instance of the PdfRectangle class from a serialized XML element. More...
 
 PdfRectangle (PdfRectangle other)
 Initializes a new instance as a copy of the specified PdfRectangle. More...
 
 PdfRectangle (IReadOnlyList< PdfRectangle > bounds)
 Initializes a new instance of the PdfRectangle as the union of the specified list of rectangles. More...
 
void CopyFrom (PdfRectangle rect)
 Copy coordinates, BUT NOT THE ANGLE, from another instance of PdfRectangle. More...
 
double[] ToArray ()
 Converts coordinates to an array of double precision numbers. More...
 
bool Contains (PdfPoint point)
 Determines if the rectangle contains the specified point. More...
 
bool Contains (PdfRectangle rc)
 Determines if the current rectangle contains the specified rectangle. More...
 
bool ContainsOrIntersects (PdfRectangle rc)
 Determines if the current rectangle contains or intersects the specified rectangle. More...
 
void Inflate (PdfSize size)
 Inflates the rectangle by specified size in each direction. More...
 
void Deflate (PdfSize size)
 Deflates the rectangle by specified size in each direction. More...
 
bool VerticalOverlaps (PdfRectangle rc)
 Checks whether this rectangle has a vertical overlap with another rectangle. More...
 
double VerticalOverlap (PdfRectangle rc)
 Computes relative vertical overlap with another rectangle. More...
 
bool HorizontalOverlaps (PdfRectangle rc)
 Checks whether this rectangle has a horizontal overlap with another rectangle. More...
 
double HorizontalOverlap (PdfRectangle rc)
 Computes relative horizontal overlap with another rectangle. More...
 
void Union (PdfRectangle rc)
 Merges the specified rectangle into the current one. More...
 
bool Intersects (PdfRectangle rc)
 Checks whether this rectangle intersects with the specified rectangle. More...
 
void Intersect (PdfRectangle rc)
 Make this object the intersection of itself with a specified rectangle. More...
 
void SetEmpty ()
 Set this object to an empty rectangle with zero sides.
 
void Normalize ()
 Normalizes the rectangle so that Right >= Left and Top >= Bottom.
 
PdfRectangle Rotate (int angle, double pageWidth, double pageHeight)
 Rotate rectangle counterclockwise about the origin of the page where it is defined in 90 degree intervals. More...
 
override string ToString ()
 Converts this object to a human-readable string. More...
 
bool Equals (PdfRectangle other)
 Compares this instance to the specified instance. More...
 
bool Equals (PdfRectangle other, double tolerance)
 Compares this instance to the specified other instance for approximate equality within the given tolerance. More...
 
override bool Equals (object obj)
 Compares this instance to the specified object. More...
 
override int GetHashCode ()
 Gets a custom hash code for this instance. More...
 
void FromXml (XElement xml, int scale)
 Initializes a new instance from a serialized XML element. More...
 
XElement ToXml (string root, int scale)
 Serializes the current instance as an XML element. More...
 

Static Public Member Functions

static int CenterComparer (PdfRectangle a, PdfRectangle b, double tolerance=0.1)
 Compares centers of rectangles for top-down, left-right sorting. More...
 

Public Attributes

double Left
 The left coordinate of the rectangle.
 
double Top
 The top coordinate of the rectangle.
 
double Right
 The right coordinate of the rectangle.
 
double Bottom
 The bottom coordinate of the rectangle.
 

Static Public Attributes

static readonly PdfRectangle Empty = new PdfRectangle()
 Represents a PdfRect that has coordinates set to zero.
 

Properties

double X [get]
 The X coordinate or the rectangle (bottom-left corner).
 
double Y [get]
 The Y coordinate or the rectangle (bottom-left corner).
 
double Width [get, set]
 Gets the width of the rectangle.
 
double Height [get, set]
 Gets the height of the rectangle.
 
PdfPoint TopLeft [get]
 Gets the top-left point of the rectangle.
 
PdfPoint TopRight [get]
 Gets the top-right point of the rectangle.
 
PdfPoint BottomLeft [get]
 Gets the bottom-left point of the rectangle.
 
PdfPoint BottomRight [get]
 Gets the bottom-right point of the rectangle.
 
PdfPoint Center [get]
 Gets the center point of the rectangle.
 
bool IsEmpty [get]
 Gets a flag to indicate an empty rectangle within a tolerance.
 
bool IsNormalized [get]
 Gets a flag to indicate whether the rectangle is normalized.
 
int Angle [get, set]
 Gets or sets the rotation angle, counterclockwise, in degrees. Supported values are 0, 90 and 270. Used in text processing.
 
bool IsVertical [get]
 Gets a flag to indicate whether the character is vertically rotated.
 

Detailed Description

Class represents a rectangular region in PDF world coordinates. The rectangle is kept normalized.

Constructor & Destructor Documentation

◆ PdfRectangle() [1/4]

Opait.Pdf.Api.PdfRectangle.PdfRectangle ( double  left,
double  top,
double  right,
double  bottom 
)

Initializes a new instance of the PdfRectangle class with specified coordinates.

Parameters
leftThe left coordinate of the rectangle.
topThe top coordinate of the rectangle.
rightThe left coordinate of the rectangle.
bottomThe bottom coordinate of the rectangle.

◆ PdfRectangle() [2/4]

Opait.Pdf.Api.PdfRectangle.PdfRectangle ( XElement  xml,
int  scale 
)

Initializes a new instance of the PdfRectangle class from a serialized XML element.

Parameters
xmlThe serialized XML element.
scaleA scale factor for saving as integers.

◆ PdfRectangle() [3/4]

Opait.Pdf.Api.PdfRectangle.PdfRectangle ( PdfRectangle  other)

Initializes a new instance as a copy of the specified PdfRectangle.

Parameters
otherThe source rectangle.

◆ PdfRectangle() [4/4]

Opait.Pdf.Api.PdfRectangle.PdfRectangle ( IReadOnlyList< PdfRectangle bounds)

Initializes a new instance of the PdfRectangle as the union of the specified list of rectangles.

Parameters
boundsThe list of existing rectangles.

Member Function Documentation

◆ CenterComparer()

static int Opait.Pdf.Api.PdfRectangle.CenterComparer ( PdfRectangle  a,
PdfRectangle  b,
double  tolerance = 0.1 
)
static

Compares centers of rectangles for top-down, left-right sorting.

Parameters
aFirst rectangle to compare.
bSecond rectangle to compare.
toleranceComparison tolerance.
Returns
The lexical relationship between the two comparands.

◆ Contains() [1/2]

bool Opait.Pdf.Api.PdfRectangle.Contains ( PdfPoint  point)

Determines if the rectangle contains the specified point.

Parameters
pointThe point to check.
Returns
'true' if the rectangle contains the point; otherwise, 'false'.

◆ Contains() [2/2]

bool Opait.Pdf.Api.PdfRectangle.Contains ( PdfRectangle  rc)

Determines if the current rectangle contains the specified rectangle.

Parameters
rcThe rectangle to check.
Returns
'true' if this rectangle contains the specified rectangle; otherwise, 'false'.

◆ ContainsOrIntersects()

bool Opait.Pdf.Api.PdfRectangle.ContainsOrIntersects ( PdfRectangle  rc)

Determines if the current rectangle contains or intersects the specified rectangle.

Parameters
rcThe rectangle to check.
Returns
'true' if this rectangle contains or intersects the specified rectangle; otherwise, 'false'.

◆ CopyFrom()

void Opait.Pdf.Api.PdfRectangle.CopyFrom ( PdfRectangle  rect)

Copy coordinates, BUT NOT THE ANGLE, from another instance of PdfRectangle.

Parameters
rectThe rectangle to copy from.

◆ Deflate()

void Opait.Pdf.Api.PdfRectangle.Deflate ( PdfSize  size)

Deflates the rectangle by specified size in each direction.

Parameters
sizeThe size of the deflate.

◆ Equals() [1/3]

override bool Opait.Pdf.Api.PdfRectangle.Equals ( object  obj)

Compares this instance to the specified object.

Parameters
objThe object to compare with.
Returns
'true' if this instance is equal to the specified object; otherwise, 'false'.

◆ Equals() [2/3]

bool Opait.Pdf.Api.PdfRectangle.Equals ( PdfRectangle  other)

Compares this instance to the specified instance.

Parameters
otherThe specified instance to compare with.
Returns
'true' if this instance is the same as the specified instance; otherwise, 'false'.

◆ Equals() [3/3]

bool Opait.Pdf.Api.PdfRectangle.Equals ( PdfRectangle  other,
double  tolerance 
)

Compares this instance to the specified other instance for approximate equality within the given tolerance.

Parameters
otherThe specified instance to compare with.
toleranceThe comparison tolerance value.
Returns
'true' if this instance is approximately the same as the specified instance; otherwise, 'false'.

◆ FromXml()

void Opait.Pdf.Api.PdfRectangle.FromXml ( XElement  xml,
int  scale 
)

Initializes a new instance from a serialized XML element.

Parameters
xmlThe serialized XML element.
scaleA scale factor used in saving as integers.

◆ GetHashCode()

override int Opait.Pdf.Api.PdfRectangle.GetHashCode ( )

Gets a custom hash code for this instance.

Returns
A unique hash code representing this instance.

◆ HorizontalOverlap()

double Opait.Pdf.Api.PdfRectangle.HorizontalOverlap ( PdfRectangle  rc)

Computes relative horizontal overlap with another rectangle.

Parameters
rcThe rectangle to compare with.
Returns
The amount of horizontal overlap between this rectangle and the specified rectangle. A zero or negative value indicates no overlap.

◆ HorizontalOverlaps()

bool Opait.Pdf.Api.PdfRectangle.HorizontalOverlaps ( PdfRectangle  rc)

Checks whether this rectangle has a horizontal overlap with another rectangle.

Parameters
rcThe rectangle to check.
Returns
'true' if this rectangle horizontally overlaps the specified rectangle; otherwise, 'false'.

◆ Inflate()

void Opait.Pdf.Api.PdfRectangle.Inflate ( PdfSize  size)

Inflates the rectangle by specified size in each direction.

Parameters
sizeThe size of the inflate.

◆ Intersect()

void Opait.Pdf.Api.PdfRectangle.Intersect ( PdfRectangle  rc)

Make this object the intersection of itself with a specified rectangle.

Parameters
rcThe rectangle to intersect with.

◆ Intersects()

bool Opait.Pdf.Api.PdfRectangle.Intersects ( PdfRectangle  rc)

Checks whether this rectangle intersects with the specified rectangle.

Parameters
rcThe rectangle to check.
Returns
'true' if this rectangle intersects with the specified rectangle; otherwise, 'false'.

◆ Rotate()

PdfRectangle Opait.Pdf.Api.PdfRectangle.Rotate ( int  angle,
double  pageWidth,
double  pageHeight 
)

Rotate rectangle counterclockwise about the origin of the page where it is defined in 90 degree intervals.

Parameters
angleCounterclockwise rotation angle in degrees.
pageWidthThe width of the page where the rectangle is defined.
pageHeightThe height of the page where the rectangle is defined.
Returns
A rotated rectangle.

◆ ToArray()

double[] Opait.Pdf.Api.PdfRectangle.ToArray ( )

Converts coordinates to an array of double precision numbers.

Returns
An array of 4 doubles.

◆ ToString()

override string Opait.Pdf.Api.PdfRectangle.ToString ( )

Converts this object to a human-readable string.

Returns
A string representing X, Width, Y, Height, Angle values.

◆ ToXml()

XElement Opait.Pdf.Api.PdfRectangle.ToXml ( string  root,
int  scale 
)

Serializes the current instance as an XML element.

Parameters
rootThe optional name of the root element.
scaleA scale factor used in saving as integers.
Returns
An XElement which represents this instance.

◆ Union()

void Opait.Pdf.Api.PdfRectangle.Union ( PdfRectangle  rc)

Merges the specified rectangle into the current one.

Parameters
rcThe rectangle to merge.

◆ VerticalOverlap()

double Opait.Pdf.Api.PdfRectangle.VerticalOverlap ( PdfRectangle  rc)

Computes relative vertical overlap with another rectangle.

Parameters
rcThe rectangle to compare with.
Returns
The amount or vertical overlap between this rectangle and the specified rectangle. A zero or negative value indicates no overlap.

◆ VerticalOverlaps()

bool Opait.Pdf.Api.PdfRectangle.VerticalOverlaps ( PdfRectangle  rc)

Checks whether this rectangle has a vertical overlap with another rectangle.

Parameters
rcThe rectangle to check.
Returns
'true' if this rectangle vertically overlaps the specified rectangle; otherwise, 'false'.