Class: Size

A size is a 2D vector that describes the size of an element. It has the values width and height. Provided values are defined in same units used by the page, point units. Point units are only equal to pixels when zoom value is 1.

It is an Immutable.Record and thus can be updated using set(key, value), for example: size.set("width", 20).

Constructor

new PSPDFKit.Geometry.Size(args)

A 2D vector that describes the size of an element.

Parameters:
Name Type Description
args object

An object used to initialize the size. If width or height is omitted, 0 will be used instead.

Default Value:
  • { width: 0, height: 0 }
Example

Create and update a size

const size = new PSPDFKit.Geometry.Size({ width: 200, height: 100 });
size = size.set("height", 200);
size.height; // => 200

Extends

  • Immutable.Record

Members

Methods




Members

height: number

The height of the size.

Type:
  • number
Default Value:
  • 0

width: number

The width of the size.

Type:
  • number
Default Value:
  • 0

Methods

ceil() → {PSPDFKit.Geometry.Size}

Returns a new size with width and height rounded to a number which is greater than or equal to the current value.

Returns:

A new Size.

Type
PSPDFKit.Geometry.Size
Example
var size = new PSPDFKit.Geometry.Size({ width: 20.5, height: 30.1 });
size.ceil(); // => Size {width: 21, height: 31}

floor() → {PSPDFKit.Geometry.Size}

Returns a new size with width and height rounded to a number which is smaller than or equal to the current value.

Returns:

A new Size.

Type
PSPDFKit.Geometry.Size
Example
var size = new PSPDFKit.Geometry.Size({ width: 20.5, height: 30.1 });
size.floor(); // => Size {width: 20, height: 30}

scale(factor) → {PSPDFKit.Geometry.Size}

Scales the width and height by a given factor.

Parameters:
Name Type Description
factor number

The scale factor.

Returns:

A new Size.

Type
PSPDFKit.Geometry.Size
Example
var size = new PSPDFKit.Geometry.Size({ width: 20, height: 30 });
size.scale(2); // => Size {width: 40, height: 60}

swapDimensions() → {PSPDFKit.Geometry.Size}

Returns a new size with the width set to the current height value and the height set to the current width value.

Returns:

A new Size.

Type
PSPDFKit.Geometry.Size
Example
var size = new PSPDFKit.Geometry.Size({ width: 20.5, height: 30.1 });
size.swapDimensions(); // => Size {width: 30.1, height: 20.5}