PageViewport

new PageViewport()

PDF page viewport created based on scale, rotation and offset.

Methods

clone(args) → {PDFJS.PageViewport}

Clones viewport with additional properties.

Parameters:
NameTypeDescription
argsObject

(optional) If specified, may contain the 'scale' or 'rotation' properties to override the corresponding properties in the cloned viewport.

Returns:

Cloned viewport.

Type: 
PDFJS.PageViewport

convertToPdfPoint(x, y) → {Object}

Converts viewport coordinates to the PDF location. For examples, useful for converting canvas pixel location into PDF one.

Parameters:
NameTypeDescription
xnumber

X coordinate.

ynumber

Y coordinate.

See
  • convertToViewportPoint
Returns:

Object that contains 'x' and 'y' properties of the point in the PDF coordinate space.

Type: 
Object

convertToViewportPoint(x, y) → {Object}

Converts PDF point to the viewport coordinates. For examples, useful for converting PDF location into canvas pixel coordinates.

Parameters:
NameTypeDescription
xnumber

X coordinate.

ynumber

Y coordinate.

See
  • convertToPdfPoint
  • convertToViewportRectangle
Returns:

Object that contains 'x' and 'y' properties of the point in the viewport coordinate space.

Type: 
Object

convertToViewportRectangle(rect) → {Array}

Converts PDF rectangle to the viewport coordinates.

Parameters:
NameTypeDescription
rectArray

xMin, yMin, xMax and yMax coordinates.

See
  • convertToViewportPoint
Returns:

Contains corresponding coordinates of the rectangle in the viewport coordinate space.

Type: 
Array