# SvgDocument

## Content

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

***

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

# Class: SvgDocument

Represents an SVG document.

## Extends

- [`ObjectBase`](ObjectBase)

## Accessors

### cursiveFont

#### Get Signature

> **get** **cursiveFont**(): [`Font`](Font) \| `null`

Gets or sets the font belonging to the Cursive font family.

##### Returns

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

#### Set Signature

> **set** **cursiveFont**(`font`): `void`

Gets or sets the font belonging to the Cursive font family.

##### Parameters

###### font

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

##### Returns

`void`

***

### description

#### Get Signature

> **get** **description**(): `string`

Gets the description of the SVG document.

##### Returns

`string`

***

### fantasyFont

#### Get Signature

> **get** **fantasyFont**(): [`Font`](Font) \| `null`

Gets or sets the font belonging to the Fantasy font family.

##### Returns

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

#### Set Signature

> **set** **fantasyFont**(`font`): `void`

Gets or sets the font belonging to the Fantasy font family.

##### Parameters

###### font

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

##### Returns

`void`

***

### fontCollection

#### Get Signature

> **get** **fontCollection**(): [`FontCollection`](FontCollection) \| `null`

Gets or sets the custom [FontCollection](FontCollection) used for searching fonts and font fallbacks.

##### Returns

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

#### Set Signature

> **set** **fontCollection**(`coll`): `void`

Gets or sets the custom [FontCollection](FontCollection) used for searching fonts and font fallbacks.

##### Parameters

###### coll

[`FontCollection`](FontCollection) | `null`

##### Returns

`void`

***

### fontFallbackScope

#### Get Signature

> **get** **fontFallbackScope**(): [`FontFallbackScope`](../enumerations/FontFallbackScope)

Gets or sets a value specifying the scope for searching fallback fonts
for the glyphs missing in the mentioned type faces.

##### Returns

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

#### Set Signature

> **set** **fontFallbackScope**(`fallbackScope`): `void`

Gets or sets a value specifying the scope for searching fallback fonts
for the glyphs missing in the mentioned type faces.

##### Parameters

###### fallbackScope

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

##### Returns

`void`

***

### id

#### Get Signature

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

Gets the reference to the object.

##### Returns

`number`

#### Inherited from

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

***

### monospaceFont

#### Get Signature

> **get** **monospaceFont**(): [`Font`](Font) \| `null`

Gets or sets the font belonging to the Monospace font family.

##### Returns

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

#### Set Signature

> **set** **monospaceFont**(`font`): `void`

Gets or sets the font belonging to the Monospace font family.

##### Parameters

###### font

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

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

***

### restrictedFontLookup

#### Get Signature

> **get** **restrictedFontLookup**(): `boolean`

Gets or sets a value indicating whether the fonts should be searched in
the custom collection only, if any specified. The default is false.

##### Returns

`boolean`

#### Set Signature

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

Gets or sets a value indicating whether the fonts should be searched in
the custom collection only, if any specified. The default is false.

##### Parameters

###### value

`boolean`

##### Returns

`void`

***

### sansSerifFont

#### Get Signature

> **get** **sansSerifFont**(): [`Font`](Font) \| `null`

Gets or sets the font belonging to the SansSerif font family.

##### Returns

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

#### Set Signature

> **set** **sansSerifFont**(`font`): `void`

Gets or sets the font belonging to the SansSerif font family.

##### Parameters

###### font

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

##### Returns

`void`

***

### serifFont

#### Get Signature

> **get** **serifFont**(): [`Font`](Font) \| `null`

Gets or sets the font belonging to the Serif font family.

##### Returns

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

#### Set Signature

> **set** **serifFont**(`font`): `void`

Gets or sets the font belonging to the Serif font family.

##### Parameters

###### font

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

##### Returns

`void`

***

### title

#### Get Signature

> **get** **title**(): `string`

Gets the title of the SVG document.

##### Returns

`string`

## Methods

### load()

#### Call Signature

> `static` **load**(`svgBytes`): `SvgDocument`

Loads a SvgDocument from a byte array.

##### Parameters

###### svgBytes

`Uint8Array`

The binary data of the SVG document.

##### Returns

`SvgDocument`

A new instance of the SVG document.

#### Call Signature

> `static` **load**(`om`, `svgBytes`): `SvgDocument`

Loads a SvgDocument from a byte array.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

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

###### svgBytes

`Uint8Array`

The binary data of the SVG document.

##### Returns

`SvgDocument`

A new instance of the SVG document.

***

### loadGz()

#### Call Signature

> `static` **loadGz**(`gzSvgBytes`): `SvgDocument`

Loads a SvgDocument from a byte array with gzipped SVG data.

##### Parameters

###### gzSvgBytes

`Uint8Array`

The binary data of the gzipped SVG document.

##### Returns

`SvgDocument`

A new instance of the SVG document.

#### Call Signature

> `static` **loadGz**(`om`, `gzSvgBytes`): `SvgDocument`

Loads a SvgDocument from a byte array with gzipped SVG data.

##### Parameters

###### om

[`ObjectManager`](ObjectManager)

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

###### gzSvgBytes

`Uint8Array`

The binary data of the gzipped SVG document.

##### Returns

`SvgDocument`

A new instance of the SVG document.

***

### addCursiveFont()

> **addCursiveFont**(`font`): `void`

Adds a font belonging to the Cursive font family.

#### Parameters

##### font

[`Font`](Font)

#### Returns

`void`

***

### addFantasyFont()

> **addFantasyFont**(`font`): `void`

Adds a font belonging to the Fantasy font family.

#### Parameters

##### font

[`Font`](Font)

#### Returns

`void`

***

### addMonospaceFont()

> **addMonospaceFont**(`font`): `void`

Adds a font belonging to the Monospace font family.

#### Parameters

##### font

[`Font`](Font)

#### Returns

`void`

***

### addSansSerifFont()

> **addSansSerifFont**(`font`): `void`

Adds a font belonging to the SansSerif font family.

#### Parameters

##### font

[`Font`](Font)

#### Returns

`void`

***

### addSerifFont()

> **addSerifFont**(`font`): `void`

Adds a font belonging to the Serif font family.

#### Parameters

##### font

[`Font`](Font)

#### Returns

`void`

***

### clearCursiveFonts()

> **clearCursiveFonts**(): `void`

Clears the list of fonts belonging to the Cursive font family.

#### Returns

`void`

***

### clearFantasyFonts()

> **clearFantasyFonts**(): `void`

Clears the list of fonts belonging to the Fantasy font family.

#### Returns

`void`

***

### clearMonospaceFonts()

> **clearMonospaceFonts**(): `void`

Clears the list of fonts belonging to the Monospace font family.

#### Returns

`void`

***

### clearSansSerifFonts()

> **clearSansSerifFonts**(): `void`

Clears the list of fonts belonging to the SansSerif font family.

#### Returns

`void`

***

### clearSerifFonts()

> **clearSerifFonts**(): `void`

Clears the list of fonts belonging to the Serif font family.

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

***

### getIntrinsicSize()

> **getIntrinsicSize**(): [`Size`](../type-aliases/Size) \| `null`

Gets the intrinsic size of SVG viewport.

#### Returns

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

The intrinsic size of SVG viewport, or null if the size is undefined.

***

### measure()

> **measure**(`x`, `y`): [`Rect`](../type-aliases/Rect)

Calculates the content bounds of an SVG document when its viewport is drawn at a specified point.

#### Parameters

##### x

`number`

The X coordinate of SVG viewport.

##### y

`number`

The Y coordinate of SVG viewport.

#### Returns

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

The content rectangle of the resulting image.

***

### measureToRect()

#### Call Signature

> **measureToRect**(`x`, `y`, `width`, `height`): [`Rect`](../type-aliases/Rect)

Calculates the content bounds of an SVG document, resizing the SVG viewport to fit into a specified rectangle.

##### Parameters

###### x

`number`

The X coordinate of the target rectangle for SVG viewport.

###### y

`number`

The Y coordinate of the target rectangle for SVG viewport.

###### width

`number`

The width of the target rectangle for SVG viewport.

###### height

`number`

The height of the target rectangle for SVG viewport.

##### Returns

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

The content rectangle of the resulting image.

#### Call Signature

> **measureToRect**(`bounds`): [`Rect`](../type-aliases/Rect)

Calculates the content bounds of an SVG document, resizing the SVG viewport to fit into a specified rectangle.

##### Parameters

###### bounds

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

The target rectangle for SVG viewport.

##### Returns

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

The content rectangle of the resulting image.

***

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

***

### save()

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

Saves the current SvgDocument to a byte array.

#### Parameters

##### options?

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

The settings for saving the document.

#### Returns

`Uint8Array`

A byte array with UTF8-encoded SVG data.

***

### saveGz()

> **saveGz**(): `Uint8Array`

Saves the current SvgDocument to a byte array in SVG.GZ format.

#### Returns

`Uint8Array`

***

### setCurrentColor()

> **setCurrentColor**(`color`): `void`

Sets the 'currentColor' value used by the SVG renderer.

#### Parameters

##### color

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

#### Returns

`void`

***

### setLanguageTags()

> **setLanguageTags**(`langTags`): `void`

Sets the list of cultures to match values of the 'systemLanguage' attribute of SVG elements.

#### Parameters

##### langTags

`string`[] | `null`

#### Returns

`void`
