Resource Base
Table of contents

Dynamsoft.DDV

Index

Handler Configuration

API Name Description
<static> setProcessingHandler() Set a processing handler to the DDV system.

Members

API Name Description
<static> documentManager DocumentManager instance.
<static> annotationManager AnnotationManager instance.

Classes

Methods

API Name Description
<static> getDefaultUiConfig() Get default UiConfig object.
<static> addFonts() Add font to library.
<static> clearLastError() Clear the last error or warning.
<static> unload() Unload all DDV resources.

Properties

API Name Description
<static> lastError Return the last error or warning.

Events

API Name Description
<static> on() Bind a listener to the specified event.
<static> off() Unbind event listener(s) from the specified event.

Integrated Events

Event Name Description
error Triggered when any error occurs.
warning Triggered when any warning occurs .
verbose Triggered when DDV is running.
info Triggered during various operations.

Handler Configuration

<static> setProcessingHandler()

Set a processing handler to the DDV system.

Syntax

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

Parameters

handlerType: The type of processing handler.

A HandlerType can be one of two types.

type HandlerType = "documentBoundariesDetect"|"imageFilter";

handler: The handler to set. Please refer to IDocumentDetect and IImageFilter.

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.

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
  • How to configure boundaries detection

Member

<static> documentManager

DocumentManager instance.

Code Snippet

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 instance.

Code Snippet

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() Get default UiConfig object.
<static> clearLastError() Clear the last error or warning.
<static> unload() Unload all DDV resources.

<static> getDefaultUiConfig()

Get default UiConfig object.

Syntax

static getDefaultUiConfig(viewerType: ViewerType, options?:DefaultUiConfigOptions): UiConfig | null;

Parameters

viewerType: A ViewerType can be one of three types.

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

options: Whether to return the configuration with annotation when viewerType = “editViewer”. Please refer to DefaultUiConfigOptions.

Return Values

The default UiConfig object for each kind of viewer.

Code Snippet

const defaultEditUi = Dynamsoft.DDV.getDefaultUiConfig("editViewer", {includeAnnotationSet: true});

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

<static> addFonts()

Add font to library.

Syntax

addFonts(fonts: Blob[]): Promise<void>;

Parameters

fonts: Specify the fonts to add.

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

static clearLastError(): void;

Remark

  • Once called this method, lastError will return undefined.

<static> unload()

Unload all DDV resources.

Syntax

static unload(): void;

Properties

API Name Description
<static> lastError Return the last error or warning.

<static> lastError

Return the last error or warning.

Syntax

static readonly lastError: DDVError;

Return Values

A DDVError object.

Events

API Name Description
<static> on() Bind a listener to the specified event.
<static> off() Unbind event listener(s) from the specified event.

<static> on()

Bind a listener to the specified event.

Syntax

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

Parameters

eventName: Specify the event name. It should be an integrated event name.

listener: Specify the listener.

Code Snippet

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

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

Parameters

eventName: Specify the event name. It should be an integrated event name.

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

Code Snippet

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 Triggered when any error occurs.
warning Triggered when any warning occurs.
verbose Triggered when DDV is running.
info Triggered during various operations.

error

Triggered when any error occurs.

Callback

An EventObject which contains the detailed error info.

Attributes

DDVError: Detailed error info.

warning

Triggered when any warning occurs.

Callback

An EventObject which contains the detailed warning info.

Attributes

DDVError: Detailed warning info.

verbose

Triggered when DDV is running.

Callback

EventObject array which contain the detailed verbose info.

Example

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

See InfoObject for details.

Callback

InfoObject which contains different attributes depending on the type of event.

Example

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

This page is compatible for:

Is this page helpful?

YesYes NoNo

In this article: