Top Description Fields Constructors Methods
org.apache.pdfbox.pdmodel.common

public Class PDRectangle

extends Object
implements COSObjectable
Class Inheritance
All Implemented Interfaces
org.apache.pdfbox.pdmodel.common.COSObjectable
Known Direct Subclasses
org.apache.pdfbox.pdmodel.common.PDImmutableRectangle
Imports
java.awt.geom.GeneralPath, .Point2D, java.util.Arrays, org.apache.pdfbox.cos.COSArray, .COSBase, .COSFloat, .COSNumber, org.apache.fontbox.util.BoundingBox, org.apache.pdfbox.util.Matrix

A rectangle in a PDF document.
Author
Ben Litchfield

Field Summary

Modifier and TypeField and Description
public static final PDRectangle
A0

An immutable rectangle the size of A0 Paper.

public static final PDRectangle
A1

An immutable rectangle the size of A1 Paper.

public static final PDRectangle
A2

An immutable rectangle the size of A2 Paper.

public static final PDRectangle
A3

An immutable rectangle the size of A3 Paper.

public static final PDRectangle
A4

An immutable rectangle the size of A4 Paper.

public static final PDRectangle
A5

An immutable rectangle the size of A5 Paper.

public static final PDRectangle
A6

An immutable rectangle the size of A6 Paper.

public static final PDRectangle
LEGAL

An immutable rectangle the size of U.S.

public static final PDRectangle
LETTER

An immutable rectangle the size of U.S.

private static final float
POINTS_PER_INCH

user space units per inch

private static final float
POINTS_PER_MM

user space units per millimeter

private final COSArray
public static final PDRectangle
TABLOID

An immutable rectangle the size of U.S.

Constructor Summary

AccessConstructor and Description
public
PDRectangle()

Constructor.

public
PDRectangle(float
The width of the rectangle.
width
,
float
The height of the rectangle.
height
)

Constructor.

public
PDRectangle(float
the x coordinate of the rectangle
x
,
float
the y coordinate of the rectangle
y
,
float
The width of the rectangle.
width
,
float
The height of the rectangle.
height
)

Constructor.

public
PDRectangle(BoundingBox
the bounding box to be used for the rectangle
box
)

Constructor.

public
PDRectangle(COSArray
An array of numbers as specified in the PDF Reference for a rectangle type.
array
)

Constructor.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

True if the point is inside this rectangle.
contains
(float
The x-coordinate to test.
x
,
float
The y-coordinate to test.
y
)

Method to determine if the x/y point is inside this rectangle.

public PDRectangle

Returns:

A new rectangle that has been translated back to the origin.
createRetranslatedRectangle
()

This will create a translated rectangle based off of this rectangle, such that the new rectangle retains the same dimensions(height/width), but the lower left x,y values are zero.

public COSArray

Returns:

The cos array.
getCOSArray
()

This will get the underlying array for this rectangle.

public COSBase

Returns:

The cos object that matches this Java object.
getCOSObject
()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

public float

Returns:

The height of this rectangle.
getHeight
()

This will get the height of this rectangle as calculated by upperRightY - lowerLeftY.

public float

Returns:

The lower left x.
getLowerLeftX
()

This will get the lower left x coordinate.

public float

Returns:

The lower left y.
getLowerLeftY
()

This will get the lower left y coordinate.

public float

Returns:

The upper right x .
getUpperRightX
()

This will get the upper right x coordinate.

public float

Returns:

The upper right y.
getUpperRightY
()

This will get the upper right y coordinate.

public float

Returns:

The width of this rectangle.
getWidth
()

This will get the width of this rectangle as calculated by upperRightX - lowerLeftX.

public void
setLowerLeftX(float
The lower left x.
value
)

This will set the lower left x coordinate.

public void
setLowerLeftY(float
The lower left y.
value
)

This will set the lower left y coordinate.

public void
setUpperRightX(float
The upper right x .
value
)

This will set the upper right x coordinate.

public void
setUpperRightY(float
The upper right y.
value
)

This will set the upper right y coordinate.

public GeneralPath

Returns:

a general path equivalent to this rectangle
toGeneralPath
()

Returns a general path equivalent to this rectangle.

public String

Returns:

This object as a string.
toString
()

Overrides java.lang.Object.toString.

This will return a string representation of this rectangle.

public GeneralPath

Returns:

the transformed rectangle
transform
(Matrix
the matrix to be used for the transformation
matrix
)

Returns a path which represents this rectangle having been transformed by the given matrix.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

A0back to summary
public static final PDRectangle A0

An immutable rectangle the size of A0 Paper.

Annotations
@SuppressWarnings:java:S2390
A1back to summary
public static final PDRectangle A1

An immutable rectangle the size of A1 Paper.

Annotations
@SuppressWarnings:java:S2390
A2back to summary
public static final PDRectangle A2

An immutable rectangle the size of A2 Paper.

Annotations
@SuppressWarnings:java:S2390
A3back to summary
public static final PDRectangle A3

An immutable rectangle the size of A3 Paper.

Annotations
@SuppressWarnings:java:S2390
A4back to summary
public static final PDRectangle A4

An immutable rectangle the size of A4 Paper.

Annotations
@SuppressWarnings:java:S2390
A5back to summary
public static final PDRectangle A5

An immutable rectangle the size of A5 Paper.

Annotations
@SuppressWarnings:java:S2390
A6back to summary
public static final PDRectangle A6

An immutable rectangle the size of A6 Paper.

Annotations
@SuppressWarnings:java:S2390
LETTERback to summary
public static final PDRectangle LETTER

An immutable rectangle the size of U.S. Letter, 8.5" x 11".

Annotations
@SuppressWarnings:java:S2390
POINTS_PER_INCHback to summary
private static final float POINTS_PER_INCH

user space units per inch

POINTS_PER_MMback to summary
private static final float POINTS_PER_MM

user space units per millimeter

rectArrayback to summary
private final COSArray rectArray
TABLOIDback to summary
public static final PDRectangle TABLOID

An immutable rectangle the size of U.S. Tabloid, 11" x 17".

Annotations
@SuppressWarnings:java:S2390

Constructor Detail

PDRectangleback to summary
public PDRectangle()

Constructor. Initializes to 0,0,0,0

PDRectangleback to summary
public PDRectangle(float width, float height)

Constructor.

Parameters
width:float

The width of the rectangle.

height:float

The height of the rectangle.

PDRectangleback to summary
public PDRectangle(float x, float y, float width, float height)

Constructor.

Parameters
x:float

the x coordinate of the rectangle

y:float

the y coordinate of the rectangle

width:float

The width of the rectangle.

height:float

The height of the rectangle.

PDRectangleback to summary
public PDRectangle(BoundingBox box)

Constructor.

Parameters
box:BoundingBox

the bounding box to be used for the rectangle

PDRectangleback to summary
public PDRectangle(COSArray array)

Constructor.

Parameters
array:COSArray

An array of numbers as specified in the PDF Reference for a rectangle type.

Method Detail

containsback to summary
public boolean contains(float x, float y)

Method to determine if the x/y point is inside this rectangle.

Parameters
x:float

The x-coordinate to test.

y:float

The y-coordinate to test.

Returns:boolean

True if the point is inside this rectangle.

createRetranslatedRectangleback to summary
public PDRectangle createRetranslatedRectangle()

This will create a translated rectangle based off of this rectangle, such that the new rectangle retains the same dimensions(height/width), but the lower left x,y values are zero.
100, 100, 400, 400 (llx, lly, urx, ury )
will be translated to 0,0,300,300

Returns:PDRectangle

A new rectangle that has been translated back to the origin.

getCOSArrayback to summary
public COSArray getCOSArray()

This will get the underlying array for this rectangle.

Returns:COSArray

The cos array.

getCOSObjectback to summary
public COSBase getCOSObject()

Implements org.apache.pdfbox.pdmodel.common.COSObjectable.getCOSObject.

Convert this standard java object to a COS object.

Returns:COSBase

The cos object that matches this Java object.

Annotations
@Override
getHeightback to summary
public float getHeight()

This will get the height of this rectangle as calculated by upperRightY - lowerLeftY.

Returns:float

The height of this rectangle.

getLowerLeftXback to summary
public float getLowerLeftX()

This will get the lower left x coordinate.

Returns:float

The lower left x.

getLowerLeftYback to summary
public float getLowerLeftY()

This will get the lower left y coordinate.

Returns:float

The lower left y.

getUpperRightXback to summary
public float getUpperRightX()

This will get the upper right x coordinate.

Returns:float

The upper right x .

getUpperRightYback to summary
public float getUpperRightY()

This will get the upper right y coordinate.

Returns:float

The upper right y.

getWidthback to summary
public float getWidth()

This will get the width of this rectangle as calculated by upperRightX - lowerLeftX.

Returns:float

The width of this rectangle.

setLowerLeftXback to summary
public void setLowerLeftX(float value)

This will set the lower left x coordinate.

Parameters
value:float

The lower left x.

setLowerLeftYback to summary
public void setLowerLeftY(float value)

This will set the lower left y coordinate.

Parameters
value:float

The lower left y.

setUpperRightXback to summary
public void setUpperRightX(float value)

This will set the upper right x coordinate.

Parameters
value:float

The upper right x .

setUpperRightYback to summary
public void setUpperRightY(float value)

This will set the upper right y coordinate.

Parameters
value:float

The upper right y.

toGeneralPathback to summary
public GeneralPath toGeneralPath()

Returns a general path equivalent to this rectangle. This method avoids the problems caused by Rectangle2D not working well with -ve rectangles.

Returns:GeneralPath

a general path equivalent to this rectangle

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

This will return a string representation of this rectangle.

Returns:String

This object as a string.

Annotations
@Override
transformback to summary
public GeneralPath transform(Matrix matrix)

Returns a path which represents this rectangle having been transformed by the given matrix. Note that the resulting path need not be rectangular.

Parameters
matrix:Matrix

the matrix to be used for the transformation

Returns:GeneralPath

the transformed rectangle