Table of contents

Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!

Your download will start shortly. If your download does not begin, click here to retry.

{WebTwainObject} Util

The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the WebTwain instance. Learn about how to create a web twain object.

Methods

RegisterEvent() UnregisterEvent() GenerateURLForUploadData()

Properties

ErrorCode ErrorCause ErrorString LogLevel Manufacturer
ProductFamily ProductName VersionInfo    

RegisterEvent()

Specify an event listener for the specified built-in event.

Syntax

RegisterEvent(name: string, callback: (...arg: any[]) => void): boolean;

Parameters

name: Specify the event.

callback: The event listener.

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

There can only be one listener for each built-in event. If you call RegisterEvent on the same event again, the new callback will replace the old one.


UnregisterEvent()

Remove an event listener from the specified built-in event.

Syntax

UnregisterEvent(name: string, callback?: (...arg: any[]) => void): boolean;

Parameters

name: Specify the event.

callback: The event listener.

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

GenerateURLForUploadData()

Generate a URL to be used by a FileUpoader instance to fetch the data to upload.

Syntax

GenerateURLForUploadData(
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: (
        resultURL: string,
        indices: number[],
        type: Dynamsoft.DWT.EnumDWT_ImageType | number
    ) => void,
    failureCallback: (
        errorCode: number,
        errorString: string
    ) => void
): void;

Parameters

indices: Specify the images to upload.

type: Specify the file type. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

  • resultURL: The generated URL.
  • indices: The indices of the images.
  • type: The file type. Please refer to EnumDWT_ImageType.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v14.0+ v15.1+ v15.1+ v15.1+

Example

var dsUploadManager;
Dynamsoft.FileUploader.Init(
  "",
  function (obj) {
    dsUploadManager = obj;
  },
  function () {}
);
DWTObject.GenerateURLForUploadData(
  [0, 1],
  EnumDWT_ImageType.IT_PDF,
  function (resultURL, newIndices, enumImageType) {
    var serverUrl = "https://yoursite/yourserverurl.aspx";
    var jobtemp = dsUploadManager.CreateJob();
    jobtemp.ServerUrl = serverUrl;
    jobtemp.SourceValue.Add(resultURL, "uploadedFile.pdf");
    dsUploadManager.Run(jobtemp);
  },
  function (
    erroCode,
    errorString
  ) {}
);

ErrorCode

Return the error code.

Syntax

readonly ErrorCode: number;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

The ErrorCode and ErrorString always reflect the result of the last API call. So make sure you read them in time.


ErrorCause

Return the error cause from the operating system.

Syntax

readonly ErrorCause: null | {code: number, message: string};

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v19.0+ v19.0+ v19.0+ v19.0+

ErrorString

Return the error string.

Syntax

readonly ErrorString: string;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

The ErrorCode and ErrorString always reflect the result of the last API call. So make sure you read them in time.


LogLevel

Return or set the log level for debugging.

Syntax

LogLevel: number;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

The logs for the Dynamic Web TWAIN library are saved in the directory:

  • Windows C:\Program Files (x86)\Dynamsoft\Dynamic Web TWAIN Service {versionnumber}\log(version 18.5.1 and earlier C:\Windows\SysWOW64\Dynamsoft\DynamsoftServicex64_{versionnumber}\log) or C:\Users\{UserName}\AppData\Roaming\Dynamsoft\Dynamic Web TWAIN Service\log(version 18.5.1 and earlier C:\Users\{UserName}\AppData\Roaming\Dynamsoft\DynamsoftService\log)
  • macOS, Go > Applications > Dynamsoft > Dynamic Web TWAIN Service {versionnumber} > log(version 18.5.1 and earlier Go > Applications > Dynamsoft > DynamsoftServicex64_{versionnumber} > {installed version No.} > log)
  • Linux: /opt/dynamsoft/Dynamic Web TWAIN Service {versionnumber}/log(version 18.5.1 and earlier /opt/dynamsoft/DynamsoftService/log)

By default, LogLevel is 0 and nothing is recorded. When it is set to 1, all debugging information is recorded. This setting in your application will apply to all machines. Please set it back to 0 if you don’t need to record log as it will slow down the speed.


Manufacturer

Manufacturer in the identity string of the Dynamic Web TWAIN library.

Syntax

readonly Manufacturer: string;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

Manufacturer, ProductFamily, ProductName and VersionInfo together form the identity string of the Dynamic Web TWAIN library.


ProductFamily

ProductFamily in the identity string of the Dynamic Web TWAIN library.

Syntax

readonly ProductFamily: string;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

Manufacturer, ProductFamily, ProductName and VersionInfo together form the identity string of the Dynamic Web TWAIN library.


ProductName

ProductName in the identity string of the Dynamic Web TWAIN library.

Syntax

readonly ProductName: string;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

Manufacturer, ProductFamily, ProductName and VersionInfo together form the identity string of the Dynamic Web TWAIN library.


VersionInfo

VersionInfo in the identity string of the Dynamic Web TWAIN library.

Syntax

readonly VersionInfo: string;

Availability

H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

Manufacturer, ProductFamily, ProductName and VersionInfo together form the identity string of the Dynamic Web TWAIN library.