Table of Contents

Struct PdfRectangle

Namespace
UglyToad.PdfPig.Core
Assembly
UglyToad.PdfPig.Core.dll

A rectangle in a PDF file.

public struct PdfRectangle
Inherited Members

Remarks

PDF coordinates are defined with the origin at the lower left (0, 0). The Y-axis extends vertically upwards and the X-axis horizontally to the right. Unless otherwise specified on a per-page basis, units in PDF space are equivalent to a typographic point (1/72 inch).

Constructors

PdfRectangle(double, double, double, double)

Create a new PdfRectangle.

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

Parameters

x1 double

Bottom left point's x coordinate of the rectangle.

y1 double

Bottom left point's y coordinate of the rectangle.

x2 double

Top right point's x coordinate of the rectangle.

y2 double

Top right point's y coordinate of the rectangle.

PdfRectangle(short, short, short, short)

Create a new PdfRectangle.

public PdfRectangle(short x1, short y1, short x2, short y2)

Parameters

x1 short

Bottom left point's x coordinate of the rectangle.

y1 short

Bottom left point's y coordinate of the rectangle.

x2 short

Top right point's x coordinate of the rectangle.

y2 short

Top right point's y coordinate of the rectangle.

PdfRectangle(PdfPoint, PdfPoint)

Create a new PdfRectangle.

public PdfRectangle(PdfPoint bottomLeft, PdfPoint topRight)

Parameters

bottomLeft PdfPoint

Bottom left point of the rectangle.

topRight PdfPoint

Top right point of the rectangle.

PdfRectangle(PdfPoint, PdfPoint, PdfPoint, PdfPoint)

Create a new PdfRectangle.

public PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft, PdfPoint bottomRight)

Parameters

topLeft PdfPoint
topRight PdfPoint
bottomLeft PdfPoint
bottomRight PdfPoint

Properties

Area

Area of the rectangle.

public double Area { get; }

Property Value

double

Bottom

Bottom. This value is only valid if the rectangle is not rotated, check Rotation.

public double Bottom { get; }

Property Value

double

BottomLeft

Bottom left point of the rectangle.

public readonly PdfPoint BottomLeft { get; }

Property Value

PdfPoint

BottomRight

Bottom right point of the rectangle.

public readonly PdfPoint BottomRight { get; }

Property Value

PdfPoint

Centroid

Centroid point of the rectangle.

public PdfPoint Centroid { get; }

Property Value

PdfPoint

Height

Height of the rectangle.

A positive number.

public double Height { get; }

Property Value

double

Left

Left. This value is only valid if the rectangle is not rotated, check Rotation.

public double Left { get; }

Property Value

double

Right

Right. This value is only valid if the rectangle is not rotated, check Rotation.

public double Right { get; }

Property Value

double

Rotation

Rotation angle of the rectangle. Counterclockwise, in degrees.

-180 ≤ θ ≤ 180

public double Rotation { get; }

Property Value

double

Top

Top. This value is only valid if the rectangle is not rotated, check Rotation.

public double Top { get; }

Property Value

double

TopLeft

Top left point of the rectangle.

public readonly PdfPoint TopLeft { get; }

Property Value

PdfPoint

TopRight

Top right point of the rectangle.

public readonly PdfPoint TopRight { get; }

Property Value

PdfPoint

Width

Width of the rectangle.

A positive number.

public double Width { get; }

Property Value

double

Methods

ToString()

public override string ToString()

Returns

string

Translate(double, double)

Creates a new PdfRectangle which is the current rectangle moved in the x and y directions relative to its current position by a value.

public PdfRectangle Translate(double dx, double dy)

Parameters

dx double

The distance to move the rectangle in the x direction relative to its current location.

dy double

The distance to move the rectangle in the y direction relative to its current location.

Returns

PdfRectangle

A new rectangle shifted on the y axis by the given delta value.