| 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 |
Handler Configuration
| API Name | Description |
|---|---|
<static> setProcessingHandler() |
Set a processing handler to the DDV system. |
Members
| API Name | Description |
|---|---|
<static> documentManager |
[DocumentManager]({{ site.api }}class/documentmanager.html) instance. |
<static> annotationManager |
[AnnotationManager]({{ site.api }}class/annotationmanager.html) instance. |
Classes
-
[DocumentManager]({{ site.api }}class/documentmanager.html)
-
[AnnotationManager]({{ site.api }}class/annotationmanager.html)
-
[EditViewer]({{ site.api }}class/editviewer.html)
-
[CaptureViewer]({{ site.api }}class/captureviewer.html)
-
[PerspectiveViewer]({{ site.api }}class/perspectiveviewer.html)
-
[BrowseViewer]({{ site.api }}class/browseviewer.html)
-
[CustomViewer]({{ site.api }}class/customviewer.html)
-
Advanced
- [ImageFilter]({{ site.api }}class/advanced/imagefilter.html)
- [DocumentDetect]({{ site.api }}class/advanced/documentdetect.html)
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. |
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]({{ site.api }}interface/idocumentdetect.html) and [IImageFilter]({{ site.api }}interface/iimagefilter.html).
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
documentBoundariesDetecthandler is not set, the default elementDynamsoft.DDV.Elements.AutoDetectwill be disabled. - If
imageFilterhandler is not set, the default elementDynamsoft.DDV.Elements.Filterwill be disabled. - [How to configure image filter]({{ site.features }}advanced/imagefilter.html)
- [How to configure boundaries detection]({{ site.features }}advanced/documentdetect.html)
[DocumentManager]({{ site.api }}class/documentmanager.html) 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;[AnnotationManager]({{ site.api }}class/annotationmanager.html) 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;| API Name | Description |
|---|---|
<static> getDefaultUiConfig() |
Get default UiConfig object. |
<static> clearLastError() |
Clear the last error or warning. |
<static> unload() |
Unload all DDV resources. |
Get default UiConfig object.
Syntax
static getDefaultUiConfig(viewerType: ViewerType): UiConfig | null;Parameters
viewerType: A ViewerType can be one of four types.
type ViewerType = "editViewer"|"captureViewer"|"perspectiveViewer"|"browseViewer";Return Values
The [default UiConfig]({{ site.ui }}default_ui.html) object for each kind of viewer.
Code Snippet
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 |
Add font to library. You can fetch a font via an URL or use the queryLocalFonts() API to get the fonts installed on the local system.
Syntax
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. |
Clear the last error or warning.
Syntax
static clearLastError(): void;Remark
- Once called this method,
lastErrorwill returnundefined.
Unload all DDV resources.
Syntax
static unload(): void;| API Name | Description |
|---|---|
<static> lastError |
Return the last error or warning. |
Return the last error or warning.
Syntax
static readonly lastError: DDVError;Return Values
A [DDVError]({{ site.api }}interface/ddverror.html) object.
| API Name | Description |
|---|---|
<static> on() |
Bind a listener to the specified event. |
<static> off() |
Unbind event listener(s) from the specified event. |
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. |
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. |
| 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. |
Triggered when any error occurs.
Callback
An EventObject which contains the detailed error info.
Attributes
[DDVError]({{ site.api }}interface/ddverror.html): Detailed error info.
Triggered when any warning occurs.
Callback
An EventObject which contains the detailed warning info.
Attributes
[DDVError]({{ site.api }}interface/ddverror.html): Detailed warning info.
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);
}
});Triggered for any of the following tasks:
initloadSourcesavefilterperspectiveloadWasm
See [InfoObject]({{ site.api }}interface/infoobject.html) for details.
Callback
[InfoObject]({{ site.api }}interface/infoobject.html) 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")
}
})