---
layout: default-layout
needAutoGenerateSidebar: true
title: Dynamic Web TWAIN SDK API Reference - Utility APIs
keywords: Dynamic Web TWAIN, Documentation, API Reference, Utility APIs
breadcrumbText: Utility
description: Dynamic Web TWAIN SDK Documentation API Reference Utility APIs Page
---

# {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](https://www.dynamsoft.com/web-twain/docs/extended-usage/advanced-initialization.md#instantiating-webtwain-without-onwebtwainready).

**Methods**

| [`RegisterEvent()`](#registerevent) | [`UnregisterEvent()`](#unregisterevent) | [`GenerateURLForUploadData()`](#generateurlforuploaddata) |

**Properties**


| [`ErrorCode`](#errorcode)       | [`ErrorCause`](#errorcause)       | [`ErrorString`](#errorstring) | [`LogLevel`](#loglevel)       |
| [`Manufacturer`](#manufacturer) | [`ProductFamily`](#productfamily) | [`ProductName`](#productname) | [`VersionInfo`](#versioninfo) |


---

## RegisterEvent()

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

**Syntax**

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

**Parameters**

`name`: Specify the event.

`callback`: The event listener.

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**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**

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

**Parameters**

`name`: Specify the event.

`callback`: The event listener.

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

---

## GenerateURLForUploadData()

Generate a URL to be used by a [FileUploader](https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_FileUploader.md) instance to fetch the data to upload.

**Syntax**

```typescript
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`](https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_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`](https://www.dynamsoft.com/web-twain/docs/info/api/Dynamsoft_Enum.md#dynamsoftdwtenumdwt_imagetype).

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

- `errorCode`: The error code.
- `errorString`: The error string.

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v14.0+ </td>
<td align="center">v15.1+ </td>
<td align="center">v15.1+ </td>
<td align="center">v15.1+ </td>
</tr>

</table>
</div>

**Example**

```javascript
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 (errorCode, errorString) {},
);
```

---

## ErrorCode

Return the error code.

**Syntax**

```typescript
readonly ErrorCode: number;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

The [`ErrorCode`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#errorcode) and [`ErrorString`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#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**

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

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v19.0+ </td>
<td align="center">v19.0+ </td>
<td align="center">v19.0+ </td>
<td align="center">v19.0+ </td>
</tr>

</table>
</div>

---

## ErrorString

Return the error string.

**Syntax**

```typescript
readonly ErrorString: string;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

The [`ErrorCode`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#errorcode) and [`ErrorString`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#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**

```typescript
LogLevel: number;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

The logs for the Dynamic Web TWAIN library are saved in the `log` folder under its [installation folder](https://www.dynamsoft.com/web-twain/docs/extended-usage/dynamsoft-service-configuration.md#installation-folder).

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**

```typescript
readonly Manufacturer: string;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

[`Manufacturer`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productfamily), [`ProductName`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#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**

```typescript
readonly ProductFamily: string;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

[`Manufacturer`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productfamily), [`ProductName`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#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**

```typescript
readonly ProductName: string;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

[`Manufacturer`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productfamily), [`ProductName`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#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**

```typescript
readonly VersionInfo: string;
```

**Availability**

<div class="availability">
<table>

<tr>
<td align="center">H5(Windows)</td>
<td align="center">H5(macOS/TWAIN)</td>
<td align="center">H5(macOS/ICA)</td>
<td align="center">H5(Linux)</td>
</tr>

<tr>
<td align="center">v10.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v11.0+ </td>
<td align="center">v12.1+ </td>
</tr>

</table>
</div>

**Usage notes**

[`Manufacturer`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#manufacturer), [`ProductFamily`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productfamily), [`ProductName`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#productname) and [`VersionInfo`](https://www.dynamsoft.com/web-twain/docs/info/api/WebTwain_Util.md#versioninfo) together form the identity string of the Dynamic Web TWAIN library.

<div class="multi-panel-switching-end"></div>
