# Pen

## Content

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

***

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

# Class: Pen

Represents a pen used to draw lines and contours.

## Extends

- [`ObjectBase`](ObjectBase)

## Constructors

### Constructor

> **new Pen**(`penProperties`): `Pen`

Creates a new Pen based on properties of an existing Pen.

#### Parameters

##### penProperties

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

The settings overriding properties of the base Pen.

#### Returns

`Pen`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new Pen**(`basePen`, `penProperties`): `Pen`

Creates a new Pen based on properties of an existing Pen.

#### Parameters

##### basePen

`Pen`

The Pen used as the base for the new Pen.

##### penProperties

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

The settings overriding properties of the base Pen.

#### Returns

`Pen`

#### Overrides

`ObjectBase.constructor`

### Constructor

> **new Pen**(`om`, `penProperties`): `Pen`

Creates a new Pen object with specified properties.

#### Parameters

##### om

[`ObjectManager`](ObjectManager)

An object manager that controls the lifetime of the Pen object.

##### penProperties

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

The settings for creating a Pen.

#### Returns

`Pen`

#### Overrides

`ObjectBase.constructor`

## Accessors

### color

#### Get Signature

> **get** **color**(): [`Color`](../type-aliases/Color)

Gets the pen color.

##### Returns

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

***

### dashOffset

#### Get Signature

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

Gets the distance within the dash pattern where a dash begins.

##### Returns

`number`

***

### dashPattern

#### Get Signature

> **get** **dashPattern**(): `number`[] \| `null`

Gets the custom dash pattern of lines drawn with this pen.

##### Returns

`number`[] \| `null`

***

### dashStyle

#### Get Signature

> **get** **dashStyle**(): [`DashStyle`](../enumerations/DashStyle)

Gets the style of dashed lines drawn with this pen.

##### Returns

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

***

### id

#### Get Signature

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

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

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

***

### lineCap

#### Get Signature

> **get** **lineCap**(): [`PenLineCap`](../enumerations/PenLineCap)

Gets the line cap style that specifies the shape used at the ends of open subpaths (and dashes, if any) when they are stroked.

##### Returns

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

***

### lineJoin

#### Get Signature

> **get** **lineJoin**(): [`PenLineJoin`](../enumerations/PenLineJoin)

Gets the line join style that specifies the shape used at the corners of paths that are stroked.

##### Returns

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

***

### miterLimit

#### Get Signature

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

Gets a maximum on the ratio of the miter length to the pen width. When the limit is exceeded, the join is converted from a miter to a bevel.

##### Returns

`number`

***

### om

#### Get Signature

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

Gets the owner [ObjectManager](ObjectManager) instance.

##### Returns

[`ObjectManager`](ObjectManager)

#### Inherited from

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

***

### width

#### Get Signature

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

Gets the pen width, in units used for drawing.

##### Returns

`number`

## Methods

### 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)

***

### 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)
