# PdfPage

## Content

[**DsPdfJS API v9.1.3**](../README)

***

[DsPdfJS API](../globals) / PdfPage

# Class: PdfPage

Represents a page in a [PdfDocument](PdfDocument).

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### annotations

#### Get Signature

> **get** **annotations**(): [`AnnotationCollection`](AnnotationCollection)

Gets the list of annotations associated with the PdfPage.

##### Returns

[`AnnotationCollection`](AnnotationCollection)

***

### context

#### Get Signature

> **get** **context**(): [`PdfContext`](PdfContext)

Gets a [PdfContext](PdfContext) for the current page.

##### Returns

[`PdfContext`](PdfContext)

***

### cropBox

#### Get Signature

> **get** **cropBox**(): [`Rect`](../type-aliases/Rect) \| `null`

Gets or sets a rectangle, in points, defining the visible region of default user space.
When the PdfPage is displayed or printed, its contents are to be clipped (cropped) to this
rectangle and then imposed on the output medium in some implementation-defined manner.
Default value is @mediaBox.

##### Returns

[`Rect`](../type-aliases/Rect) \| `null`

#### Set Signature

> **set** **cropBox**(`value`): `void`

Gets or sets a rectangle, in points, defining the visible region of default user space.
When the PdfPage is displayed or printed, its contents are to be clipped (cropped) to this
rectangle and then imposed on the output medium in some implementation-defined manner.
Default value is @mediaBox.

##### Parameters

###### value

[`Rect`](../type-aliases/Rect) | `null`

##### Returns

`void`

***

### document

#### Get Signature

> **get** **document**(): [`PdfDocument`](PdfDocument) \| `null`

Gets the owner [PdfDocument](PdfDocument) or null, if the PdfPage is orphan.

##### Returns

[`PdfDocument`](PdfDocument) \| `null`

***

### height

#### Get Signature

> **get** **height**(): `number`

The height of the PdfPage, in points.

##### Returns

`number`

***

### id

#### Get Signature

> **get** **id**(): `number`

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

[`ObjectBase`](ObjectBase).[`id`](ObjectBase#id)

***

### index

#### Get Signature

> **get** **index**(): `number`

Gets the index of the PdfPage in the owner [PdfPageCollection](PdfPageCollection), or -1.

##### Returns

`number`

***

### mediaBox

#### Get Signature

> **get** **mediaBox**(): [`Rect`](../type-aliases/Rect)

Gets or sets the bounds of the PdfPage in points.

##### Returns

[`Rect`](../type-aliases/Rect)

#### Set Signature

> **set** **mediaBox**(`value`): `void`

Gets or sets the bounds of the PdfPage in points.

##### Parameters

###### value

[`Rect`](../type-aliases/Rect)

##### Returns

`void`

***

### om

#### Get Signature

> **get** **om**(): [`ObjectManager`](ObjectManager)

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

[`ObjectBase`](ObjectBase).[`om`](ObjectBase#om)

***

### rotation

#### Get Signature

> **get** **rotation**(): `number`

Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed.
The value is a multiple of 90.

##### Returns

`number`

#### Set Signature

> **set** **rotation**(`degrees`): `void`

Gets or sets the number of degrees by which the PdfPage should be rotated clockwise when displayed or printed.
The value is a multiple of 90.

##### Parameters

###### degrees

`number`

##### Returns

`void`

***

### transitionDuration

#### Get Signature

> **get** **transitionDuration**(): `number` \| `null`

Gets or sets the PdfPage's display duration (also called its advance timing): the maximum length of time, in seconds,
that the page shall be displayed during presentations before the viewer application shall automatically
advance to the next page. The value of null means that the viewer shall not advance automatically.

##### Returns

`number` \| `null`

#### Set Signature

> **set** **transitionDuration**(`value`): `void`

Gets or sets the PdfPage's display duration (also called its advance timing): the maximum length of time, in seconds,
that the page shall be displayed during presentations before the viewer application shall automatically
advance to the next page. The value of null means that the viewer shall not advance automatically.

##### Parameters

###### value

`number` | `null`

##### Returns

`void`

***

### width

#### Get Signature

> **get** **width**(): `number`

The width of the PdfPage, in points.

##### Returns

`number`

## Methods

### adjustPoint()

> **adjustPoint**(`value`, `fromBottomLeft?`, `deviceDpiX?`, `deviceDpiY?`): [`Point`](../type-aliases/Point)

Converts specified visual coordinates (usually in the coordinate system with the origin
in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft')
to coordinates that take into account [PdfPage#rotation](#rotation), [PdfPage#cropBox](#cropbox)
and [PdfPage#mediaBox](#mediabox) (if 'CropBox' is not specified) values.
This method should be used when positioning annotations or destinations on a page.
Do not use this method when drawing on 'context'.

#### Parameters

##### value

[`Point`](../type-aliases/Point)

The [Point](../type-aliases/Point) to adjust.

##### fromBottomLeft?

`boolean` = `false`

If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).

##### deviceDpiX?

`number` = `72`

The horizontal device resolution.

##### deviceDpiY?

`number` = `72`

The vertical device resolution.

#### Returns

[`Point`](../type-aliases/Point)

***

### adjustQuadrilateral()

> **adjustQuadrilateral**(`value`, `fromBottomLeft?`, `deviceDpiX?`, `deviceDpiY?`): [`Quadrilateral`](../type-aliases/Quadrilateral)

Converts specified visual coordinates (usually in the coordinate system with the origin
in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft')
to coordinates that take into account [PdfPage#rotation](#rotation), [PdfPage#cropBox](#cropbox)
and [PdfPage#mediaBox](#mediabox) (if 'CropBox' is not specified) values.
This method should be used when positioning annotations or destinations on a page.
Do not use this method when drawing on 'context'.

#### Parameters

##### value

[`Quadrilateral`](../type-aliases/Quadrilateral)

The [Quadrilateral](../type-aliases/Quadrilateral) to adjust.

##### fromBottomLeft?

`boolean` = `false`

If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).

##### deviceDpiX?

`number` = `72`

The horizontal device resolution.

##### deviceDpiY?

`number` = `72`

The vertical device resolution.

#### Returns

[`Quadrilateral`](../type-aliases/Quadrilateral)

***

### adjustRect()

> **adjustRect**(`value`, `fromBottomLeft?`, `deviceDpiX?`, `deviceDpiY?`): [`Rect`](../type-aliases/Rect)

Converts specified visual coordinates (usually in the coordinate system with the origin
in the top left corner of the PdfPage and the Y axis going down, see 'fromBottomLeft')
to coordinates that take into account [PdfPage#rotation](#rotation), [PdfPage#cropBox](#cropbox)
and [PdfPage#mediaBox](#mediabox) (if 'CropBox' is not specified) values.
This method should be used when positioning annotations or destinations on a page.
Do not use this method when drawing on 'context'.

#### Parameters

##### value

[`Rect`](../type-aliases/Rect)

The [Rect](../type-aliases/Rect) to adjust.

##### fromBottomLeft?

`boolean` = `false`

If true, the source coordinates' origin is in the bottom left corner of the page with Y axis going up (by default it is in the top left corner with Y axis going down).

##### deviceDpiX?

`number` = `72`

The horizontal device resolution.

##### deviceDpiY?

`number` = `72`

The vertical device resolution.

#### Returns

[`Rect`](../type-aliases/Rect)

***

### deleteText()

#### Call Signature

> **deleteText**(`findTextParams`, `deleteTextMode`): `void`

Deletes a specified text from the PdfPage.

##### Parameters

###### findTextParams

[`FindTextParams`](../type-aliases/FindTextParams)

The text to search for.

###### deleteTextMode

[`DeleteTextMode`](../enumerations/DeleteTextMode)

The text delete mode.

##### Returns

`void`

#### Call Signature

> **deleteText**(`textMapFragment`, `deleteTextMode`): `void`

Deletes the specified text range from the PdfPage.

##### Parameters

###### textMapFragment

[`TextMapFragment`](../type-aliases/TextMapFragment)

The text range.

###### deleteTextMode

[`DeleteTextMode`](../enumerations/DeleteTextMode)

The text delete mode.

##### Returns

`void`

***

### draw()

#### Call Signature

> **draw**(`context`, `x`, `y`, `width`, `height`, `options?`): `void`

Draws the PdfPage on the given context into the specified rectangle.

##### Parameters

###### context

[`DrawingContext`](DrawingContext)

The target drawing context.

###### x

`number`

The X coordinate of the destination rectangle.

###### y

`number`

The Y coordinate of the destination rectangle.

###### width

`number`

The width of the destination rectangle.

###### height

`number`

The height of the destination rectangle.

###### options?

[`DrawPdfPageOptions`](../type-aliases/DrawPdfPageOptions)

The options for the drawing the PdfPage.

##### Returns

`void`

##### Example

```ts
const page = doc.pages.getAt(0);
const svgCtx = new SvgContext(300, 500);
page.draw(svgCtx, 0, 0, 300, 500, {
    viewStateMode: ViewStateMode.Print
});
const svgDoc = svgCtx.toSvgDocument();
```

#### Call Signature

> **draw**(`context`, `bounds`, `options?`): `void`

Draws the PdfPage on the given context into the specified rectangle.

##### Parameters

###### context

[`DrawingContext`](DrawingContext)

The target drawing context.

###### bounds

[`Bounds`](../type-aliases/Bounds)

The destination rectangle.

###### options?

[`DrawPdfPageOptions`](../type-aliases/DrawPdfPageOptions)

The options for the drawing the PdfPage.

##### Returns

`void`

***

### free()

> **free**(): `void`

Detaches the object from the [ObjectManager](ObjectManager) and deallocates its memory, if possible.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`free`](ObjectBase#free)

***

### getRenderSize()

> **getRenderSize**(`deviceDpiX?`, `deviceDpiY?`): [`Size`](../type-aliases/Size)

Gets the size of the PdfPage on a device with specified horizontal and vertical resolutions.

#### Parameters

##### deviceDpiX?

`number` = `72`

The horizontal device resolution.

##### deviceDpiY?

`number` = `72`

The vertical device resolution.

#### Returns

[`Size`](../type-aliases/Size)

***

### getText()

> **getText**(): `string`

Retrieves all text on the PdfPage.

#### Returns

`string`

***

### rebind()

> **rebind**(`omTo`): `void`

Rebinds the object from the current [ObjectManager](ObjectManager) to the specified one.

#### Parameters

##### omTo

[`ObjectManager`](ObjectManager)

The new [ObjectManager](ObjectManager) for the object.

#### Returns

`void`

#### Inherited from

[`ObjectBase`](ObjectBase).[`rebind`](ObjectBase#rebind)

***

### replaceText()

#### Call Signature

> **replaceText**(`findTextParams`, `newText`, `font?`, `fontSize?`): `void`

Replaces a specified text on the PdfPage.

Note that the results may be affected by the current value of the [PdfDocument#recognitionAlgorithm](PdfDocument#recognitionalgorithm) property.

##### Parameters

###### findTextParams

[`FindTextParams`](../type-aliases/FindTextParams)

The text to search for.

###### newText

`string`

The replacement text.

###### font?

The font to use on 'newText', if null the current font will be used.

[`Font`](Font) | `null`

###### fontSize?

The font size to use on 'newText', if null the current font size will be used.

`number` | `null`

##### Returns

`void`

#### Call Signature

> **replaceText**(`textMapFragment`, `newText`, `font?`, `fontSize?`): `void`

Replaces a specified text on the PdfPage.

Note that the results may be affected by the current value of the [PdfDocument#recognitionAlgorithm](PdfDocument#recognitionalgorithm) property.

##### Parameters

###### textMapFragment

[`TextMapFragment`](../type-aliases/TextMapFragment)

The text range.

###### newText

`string`

The replacement text.

###### font?

The font to use on 'newText', if null the current font will be used.

[`Font`](Font) | `null`

###### fontSize?

The font size to use on 'newText', if null the current font size will be used.

`number` | `null`

##### Returns

`void`

***

### saveAsPng()

> **saveAsPng**(`options?`): `Uint8Array`

Saves the PdfPage to a byte array in PNG format.

#### Parameters

##### options?

[`SaveAsImageOptions`](../type-aliases/SaveAsImageOptions)

The options for page export.

#### Returns

`Uint8Array`

The resulting binary data in PNG format.

#### Example

```ts
const doc = PdfDocument.load(data);
const page = doc.pages.getAt(0);
const imageBytes = page.saveAsPng({ backColor: "GhostWhite" });
```

***

### saveAsPngImage()

> **saveAsPngImage**(`options?`): [`Image`](Image)

Saves the PdfPage to an Image in PNG format.

#### Parameters

##### options?

[`SaveAsImageOptions`](../type-aliases/SaveAsImageOptions)

The options for page export.

#### Returns

[`Image`](Image)

The resulting Image object.

***

### saveAsSvg()

> **saveAsSvg**(`options?`): `Uint8Array`

Saves the PdfPage to a byte array in SVG format.

#### Parameters

##### options?

[`SaveAsImageOptions`](../type-aliases/SaveAsImageOptions)

The options for page export.

#### Returns

`Uint8Array`

The resulting data in UTF-8 encoded SVG format.

***

### saveAsSvgDocument()

> **saveAsSvgDocument**(`options?`): [`SvgDocument`](SvgDocument)

Saves the PdfPage as an SvgDocument.

#### Parameters

##### options?

[`SaveAsImageOptions`](../type-aliases/SaveAsImageOptions)

The options for page export.

#### Returns

[`SvgDocument`](SvgDocument)

The resulting SvgDocument object.

***

### saveAsSvgGz()

> **saveAsSvgGz**(`options?`): `Uint8Array`

Saves the PdfPage to a byte array in SVG.GZ format.

#### Parameters

##### options?

[`SaveAsImageOptions`](../type-aliases/SaveAsImageOptions)

The options for page export.

#### Returns

`Uint8Array`

The resulting binary data in SVG.GZ format.
