---
layout: default-layout
needAutoGenerateSidebar: true
needGenerateH3Content: true
noTitleIndex: true
title: Dynamsoft Document Viewer API Reference - Namespace - Dynamsoft.DDV
keywords: Documentation, Dynamsoft Document Viewer, API Reference, Namespace, Dynamsoft.DDV
breadcrumbText: Dynamsoft.DDV
description: Dynamsoft Document Viewer Documentation API Reference Namespace Dynamsoft.DDV Page
permalink: /api/namespace/ddv.html
---

# Dynamsoft.DDV

## Index

**Handler Configuration**

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> setProcessingHandler()`](#static-setprocessinghandler) | Set a processing handler to the DDV system.       |

**Members**

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> documentManager`](#static-documentmanager)   | [`DocumentManager`](https://www.dynamsoft.com/document-viewer/docs/api/class/documentmanager.md) instance.   |
| [`<static> annotationManager`](#static-annotationmanager)   | [`AnnotationManager`](https://www.dynamsoft.com/document-viewer/docs/api/class/annotationmanager.md) instance. |

**Classes**

- [DocumentManager](https://www.dynamsoft.com/document-viewer/docs/api/class/documentmanager.md)
- [AnnotationManager](https://www.dynamsoft.com/document-viewer/docs/api/class/annotationmanager.md)
- [EditViewer](https://www.dynamsoft.com/document-viewer/docs/api/class/editviewer.md)
- [CaptureViewer](https://www.dynamsoft.com/document-viewer/docs/api/class/captureviewer.md)
- [PerspectiveViewer](https://www.dynamsoft.com/document-viewer/docs/api/class/perspectiveviewer.md)
- [BrowseViewer](https://www.dynamsoft.com/document-viewer/docs/api/class/browseviewer.md)
- [CustomViewer](https://www.dynamsoft.com/document-viewer/docs/api/class/customviewer.md)

- Advanced
    - [ImageFilter](https://www.dynamsoft.com/document-viewer/docs/api/class/advanced/imagefilter.md)
    - [DocumentDetect](https://www.dynamsoft.com/document-viewer/docs/api/class/advanced/documentdetect.md)

**Methods**

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> getDefaultUiConfig()`](#static-getdefaultuiconfig)   | Get default UiConfig object.                      |
| [`<static> addFonts()`](#static-addfonts)                  | Add font to library.             |
| [`<static> clearLastError()`](#static-clearlasterror)       | Clear the last error or warning.                  |
| [`<static> unload()`](#static-unload)               | Unload all DDV resources.                         |
| [`<static> use()`](#static-use)               | Load a plugin                         |


**Properties**

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> lastError `](#static-lasterror)             | Return the last error or warning.                 |

**Events**

| API Name | Description                                        |
| -------- | -------------------------------------------------- |
| [`<static> on()`](#static-on)     | Bind a listener to the specified event.            |
| [`<static> off()`](#static-off)    | Unbind event listener(s) from the specified event. |

***Integrated Events***

| Event Name            | Description                          |
| --------------------- | ------------------------------------ |
| [`error`](#error)     | Triggered when any error occurs.     |
| [`warning`](#warning) | Triggered when any warning occurs .  |
| [`verbose`](#verbose) | Triggered when DDV is running.       |
| [`info`](#info)       | Triggered during various operations. |

## Handler Configuration

### `<static>` setProcessingHandler()

Set a processing handler to the DDV system.

**Syntax**

```typescript
static setProcessingHandler(handlerType: HandlerType, handler: any): void;
```

**Parameters**

`handlerType`: The type of processing handler. 

A `HandlerType` can be one of two types.

```typescript
type HandlerType = "documentBoundariesDetect"|"imageFilter";
```

`handler`: The handler to set. Please refer to [IDocumentDetect](https://www.dynamsoft.com/document-viewer/docs/api/interface/idocumentdetect.md) and [IImageFilter](https://www.dynamsoft.com/document-viewer/docs/api/interface/iimagefilter.md).

**Exception**

 Error Code  | Error Message                                        
--------|-----------------------------------------------------
 -80100 | *XXX(API)*: *XXX(ParameterName)* is invalid.   
 -80102 | *XXX(API)*: *XXX(ParameterName)* is missing.  
 -80103 | *XXX(API)*: The value for *XXX(ParameterName)* is not supported.
 -80500 | The '<%param%>' plugin is not installed.  

**Remark**

- Please configure the handler before creating 
- If `documentBoundariesDetect` handler is not set, the default element `Dynamsoft.DDV.Elements.AutoDetect` will be disabled.
- If `imageFilter` handler is not set, the default element `Dynamsoft.DDV.Elements.Filter` will be disabled.
- [How to configure image filter](https://www.dynamsoft.com/document-viewer/docs/features/advanced/imagefilter.md)
- [How to configure boundaries detection](https://www.dynamsoft.com/document-viewer/docs/features/advanced/documentdetect.md)

## Member

### `<static>` documentManager

[`DocumentManager`](https://www.dynamsoft.com/document-viewer/docs/api/class/documentmanager.md) instance.

**Code Snippet**

```typescript
Dynamsoft.DDV.Core.license = "Your-License-String";
Dynamsoft.DDV.Core.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/engine"; // lead to a folder containing the distributed WASM files
await Dynamsoft.DDV.Core.init(); 

const docManager = Dynamsoft.DDV.documentManager;
```

### `<static>` annotationManager

[`AnnotationManager`](https://www.dynamsoft.com/document-viewer/docs/api/class/annotationmanager.md) instance. It is `undefined` if the annotation plugin is not installed.

**Syntax**

```typescript
annotationManager: AnnotationManager | undefined;
```

**Code Snippet**

```typescript
Dynamsoft.DDV.Core.license = "Your-License-String";
Dynamsoft.DDV.Core.engineResourcePath = "https://cdn.jsdelivr.net/npm/dynamsoft-document-viewer@latest/dist/engine"; // lead to a folder containing the distributed WASM files
await Dynamsoft.DDV.Core.init(); 

const annotManager = Dynamsoft.DDV.annotationManager;
```


## Methods

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> getDefaultUiConfig()`](#static-getdefaultuiconfig)   | Get default UiConfig object.                      |
| [`<static> clearLastError()`](#static-clearlasterror)       | Clear the last error or warning.                  |
| [`<static> unload()`](#static-unload)               | Unload all DDV resources.                         |

### `<static>` getDefaultUiConfig()

Get default UiConfig object.

**Syntax**

```typescript
static getDefaultUiConfig(viewerType: ViewerType): UiConfig | null;
```

**Parameters**

`viewerType`: A `ViewerType` can be one of four types.

```typescript
type ViewerType = "editViewer"|"captureViewer"|"perspectiveViewer"|"browseViewer";
```


**Return Values**

The [default UiConfig](https://www.dynamsoft.com/document-viewer/docs/ui/default_ui.md) object for each kind of viewer.

**Code Snippet**

```typescript
const defaultEditUi = Dynamsoft.DDV.getDefaultUiConfig("editViewer");
```

**Warning**

 Error Code  | Error Message                                                           | API Return Value
--------|------------------------------------------------------------------------|----------------------
 -80100 | *XXX(API)*: *XXX(ParameterName)* is invalid.                      | `null`
 -80102 | *XXX(API)*: *XXX(ParameterName)* is missing.                     | `null`
 -80103 | *XXX(API)*: The value for *XXX(ParameterName)* is not supported.| `null`
 -80501 | Some elements are ignored because the required plugin is not installed.| `UiConfig` 


### `<static>` addFonts()

Add font to library. You can fetch a font via an URL or use the [`queryLocalFonts()`](https://developer.mozilla.org/en-US/docs/Web/API/Window/queryLocalFonts) API to get the fonts installed on the local system.

**Syntax**

```typescript
addFonts(fonts: Blob[]): Promise<string[]>;
```

**Parameters**

`fonts`: Specify the fonts to add.

**Return Values**

Array of font names.

**Exception**

 Error Code | Error Message                                               
 ---------- | ------------------------------------------------------------ 
 -80100     | *XXX(API)*: *XXX(ParameterName)* is invalid.                
 -80102     | *XXX(API)*: *XXX(ParameterName)* is missing.                



### `<static>` clearLastError()

Clear the last error or warning.

**Syntax**

```typescript
static clearLastError(): void;
```

**Remark**

- Once called this method, [`lastError`](#static-lasterror) will return `undefined`.

### `<static>` unload()

Unload all DDV resources.

**Syntax**

```typescript
static unload(): void;
```


### `<static>` use()

Load a plugin. See [Plugins and On-Demand Loading](https://www.dynamsoft.com/document-viewer/docs/features/plugins-and-on-demand-loading.md).

**Syntax**

```typescript
static use(plugin: DDVPlugin): boolean;
```

**Code Snippet**

```typescript
Dynamsoft.DDV.use(Dynamsoft.DDV.AnnotationPlugin);
Dynamsoft.DDV.use(Dynamsoft.DDV.CameraPlugin);
Dynamsoft.DDV.use(Dynamsoft.DDV.ImagePdfParserPlugin);
```

**Exception**

 Error Code | Error Message                                               
 ---------- | ------------------------------------------------------------ 
 -80100     | *XXX(API)*: *XXX(ParameterName)* is invalid.                
 -80102     | *XXX(API)*: *XXX(ParameterName)* is missing.                


## Properties

| API Name                        | Description                                       |
| ------------------------------- | ------------------------------------------------- |
| [`<static> lastError `](#static-lasterror)             | Return the last error or warning.                 |

### `<static>` lastError

Return the last error or warning.

**Syntax**

```typescript
static readonly lastError: DDVError;
```

**Return Values**

A [`DDVError`](https://www.dynamsoft.com/document-viewer/docs/api/interface/ddverror.md) object.

## Events

| API Name | Description                                        |
| -------- | -------------------------------------------------- |
| [`<static> on()`](#static-on)     | Bind a listener to the specified event.            |
| [`<static> off()`](#static-off)    | Unbind event listener(s) from the specified event. |

### `<static>` on()

Bind a listener to the specified event. 

**Syntax**

```typescript
static on(eventName: EventName, listener:(event:EventObject)=>void): void;
```

**Parameters**

`eventName`: Specify the event name. It should be [an integrated event name](#integrated-events).

`listener`: Specify the listener.

**Code Snippet**

```typescript
Dynamsoft.DDV.on("error", (e)=>{
    console.log(e.message, e.cause);
});
```

**Exception**

 Error Code  | Error Message                                        
--------|-----------------------------------------------------
 -80100 | *XXX(API)*: *XXX(ParameterName)* is invalid.   
 -80102 | *XXX(API)*: *XXX(ParameterName)* is missing.  
 -80103 | *XXX(API)*: The value for *XXX(ParameterName)* is not supported.

### `<static>` off()

Unbind event listener(s) from the specified event. 

**Syntax**

```typescript
static off(eventName: EventName, listener?:(event:EventObject)=>void): void;
```

**Parameters**

`eventName`: Specify the event name. It should be [an integrated event name](#integrated-events).

`listener`: Specify the listener. If no listener is specified, unbind all event listeners from the specified event.

**Code Snippet**

```typescript
Dynamsoft.DDV.off("error");
```

**Exception**

 Error Code  | Error Message                                        
--------|-----------------------------------------------------
 -80100 | *XXX(API)*: *XXX(ParameterName)* is invalid.   
 -80102 | *XXX(API)*: *XXX(ParameterName)* is missing.  
 -80103 | *XXX(API)*: The value for *XXX(ParameterName)* is not supported.

### Integrated Events

| Event Name            | Description                          |
| --------------------- | ------------------------------------ |
| [`error`](#error)     | Triggered when any error occurs.     |
| [`warning`](#warning) | Triggered when any warning occurs.   |
| [`verbose`](#verbose) | Triggered when DDV is running.       |
| [`info`](#info)       | Triggered during various operations. |

#### error

Triggered when any error occurs. 

**Callback**

An EventObject which contains the detailed error info.

**Attributes**

[`DDVError`](https://www.dynamsoft.com/document-viewer/docs/api/interface/ddverror.md): Detailed error info.

#### warning

Triggered when any warning occurs. 

**Callback**

An EventObject which contains the detailed warning info.

**Attributes**

[`DDVError`](https://www.dynamsoft.com/document-viewer/docs/api/interface/ddverror.md): Detailed warning info.

#### verbose

Triggered when DDV is running.

**Callback**

EventObject array which contain the detailed verbose info.

**Example**

```typescript
Dynamsoft.DDV.on("verbose", (...args) => { 
    console.log(...args); 
    if (args[0].cause) { 
        console.error(args[0].cause); 
    } 
});
```

#### info

Triggered for any of the following tasks:

- `init`
- `loadSource`
- `save`
- `filter`
- `perspective`
- `loadWasm`
- `printPreparation`

See [`InfoObject`](https://www.dynamsoft.com/document-viewer/docs/api/interface/infoobject.md) for details.

**Callback**

[`InfoObject`](https://www.dynamsoft.com/document-viewer/docs/api/interface/infoobject.md) which contains different attributes depending on the type of event.

**Example**

```js
DDV.on("info", (event) => {
    if(event.type === "loadSource" && event.status === "Pending"){
        console.log("Begin loading file")
    }
}) 
```