Dev Center
Table of contents

{WebTwainObject} Buffer Manage

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

       
ClearImageTags() RenameTag() RemoveTag() GetTagList()
FilterImagesByTag() ClearFilter() SetDefaultTag() TagImages()
GetImageBitDepth() GetImageSize() GetImageSizeWithSpecifiedType() GetSelectedImagesSize()
GetImageHeight() GetImageWidth() GetImagePartURL() GetImageURL()
GetImageXResolution() GetImageYResolution() GetSkewAngle() GetSkewAngleEx()
ImageIDToIndex() IndexToImageID() IsBlankImage() IsBlankImageExpress()
SelectAllImages() MoveImage() SwitchImage() RemoveImage()
RemoveAllImages() RemoveAllSelectedImages() SelectImages() GetTagListByIndex()
CreateFile() OpenFile() GetCurrentFileName() RemoveFile()
GetFileInfoList()      

Properties

       
BlankImageCurrentStdDev BlankImageMaxStdDev BlankImageThreshold BufferMemoryLimit
CurrentImageIndexInBuffer HowManyImagesInBuffer IfAllowLocalCache SelectedImagesIndices
MaxImagesInBuffer      

Events

       
OnBufferChanged OnBitmapChanged OnIndexChangeDragDropDone OnTopImageInTheViewChanged

IndexToImageID

Syntax

/**

* Return the imageId of an image specified by the index.
* @param index The index of the image.

*/
IndexToImageID(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.0+ v15.0+ v15.0+ v15.0+ v16.0+

ImageIDToIndex

Syntax

/**
 * Return the index of an image specified by the imageId.
 * @param imageId The imageId of the image.
 */
ImageIDToIndex(imageId: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.0+ v15.0+ v15.0+ v15.0+ v16.0+

Usage notes

An imageId is unique and won’t change as long as the Dynamsoft Service process is running. It’s a better way to keep track of an image than the index which changes easily.


RenameTag

Syntax

/**
 * Rename a tag.
 * @param oldName Specify the tag to change.
 * @param newName Specify the new tag name.
 */
RenameTag(oldName:string, newName:string): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v16.2+ v16.2+ v16.2+ v16.2+ v16.2+

RemoveTag

Syntax

/**
 * Remove the specified tag from one or more images(if not specified, remove from all).
 * @param tagName Specify the new tag name.
 * @param indices Specify the index.
 */
RemoveTag(tagName: string, indices?: number[]):boolean

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.0+ v17.0+ v17.0+ v17.0+ v17.0+

Usage Notes If the index is null, it will remove the tag you specified. If the index is not null, it will remove the specified tag on the image you selected.


GetTagList

Syntax

/**
 * Return the status of all current tags.
 */
GetTagList():Json

Json:
[
   {
        name: 'TagA',
         imageIds:''
   },
   {
        name: 'TagB',
         imageIds:[239514082, 239514083]
   },
]

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.0+ v17.0+ v17.0+ v17.0+ v17.0+

ClearImageTags

Syntax

/**
 * Remove all tags from the specified image.
 * @param index Specify the image.
 */
ClearImageTags(index: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.2+ v15.2+ v15.2+ v15.2+ v16.0+

FilterImagesByTag

Syntax

/**
 * Filter images by the specified tag.
 * @param tag The tag used as the filter. If nothing or an empty string is used, the filter is cleared.
 */
FilterImagesByTag(tag: string): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.2+ v15.2+ v15.2+ v15.2+ v16.0+

ClearFilter

Syntax

/**
 * Stop filtering images by tag.
 */
ClearFilter(): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v16.2+ v16.2+ v16.2+ v16.2+ v16.2+

SetDefaultTag

Syntax

/**
 * Set a default tag for newly acquired images.
 * @param tag Specifies the tag.
 */
SetDefaultTag(tag: string): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.2+ v15.2+ v15.2+ v15.2+ v16.0+

TagImages

Syntax

/**
 * Add a tag to specified images.
 * @param indices Specifies images to be tagged.
 * @param tag Specify the tag.
 */
TagImages(indices: number[], tag: string): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.2+ v15.2+ v15.2+ v15.2+ v16.0+

GetImageBitDepth

Syntax

/**
 * Return the pixel bit depth of the specified image.
 * @param index Specify the image.
 */
GetImageBitDepth(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v6.2+ v6.2+ v6.2+ v6.2+ v6.2+ v16.0+

GetImageHeight

Syntax

/**
 * Return the height (in pixels) of the specified image.
 * @param index Specify the image.
 */
GetImageHeight(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v6.2+ v6.2+ v6.2+ v6.2+ v6.2+ v16.0+

GetImageWidth

Syntax

/**
 * Return the width (in pixels) of the specified image.
 * @param index Specify the image.
 */
GetImageWidth(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v6.2+ v6.2+ v6.2+ v6.2+ v6.2+ v16.0+

GetImageXResolution

Syntax

/**
 * Return the horizontal resolution of the specified image.
 * @param index Specify the image.
 */
GetImageXResolution(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v8.0+ v8.0+ v8.0+ v8.0+ v8.0+ v16.0+

GetImageYResolution

Syntax

/**
 * Return the vertical resolution of the specified image.
 * @param index Specify the image.
 */
GetImageYResolution(index: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v8.0+ v8.0+ v8.0+ v8.0+ v8.0+ v16.0+

GetSkewAngle

Syntax

/**
 * Return the skew angle of the specified image.
 * @param index Specify the image.
 * @param successCallback A callback function that is executed if the request succeeds.
 * @param failureCallback A callback function that is executed if the request fails.
 * @argument angle The skew angle.
 * @argument errorCode The error code.
 * @argument errorString The error string.
 */
GetSkewAngle(
    index: number,
    successCallback?: (
        angle: number) => void,
    failureCallback?: (
        errorCode: number,
        errorString: string) => void
): number | void;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v9.0+ v9.0+ v9.0+ v9.0+ v9.0+ v16.0+

GetSkewAngleEx

Syntax

/**
 * Return the skew angle of the specified rectangle on the specified image.
 * @param index Specify the image.
 * @param left The x-coordinate of the upper-left corner of the rectangle.
 * @param top The y-coordinate of the upper-left corner of the rectangle.
 * @param right The x-coordinate of the lower-right corner of the rectangle.
 * @param bottom The y-coordinate of the lower-right corner of the rectangle.
 * @param successCallback A callback function that is executed if the request succeeds.
 * @param failureCallback A callback function that is executed if the request fails.
 * @argument angle The skew angle.
 * @argument errorCode The error code.
 * @argument errorString The error string.
 */
GetSkewAngleEx(
    index: number,
    left: number,
    top: number,
    right: number,
    bottom: number,
    successCallback?: (
        angle: number) => void,
    failureCallback?: (
        errorCode: number,
        errorString: string) => void
): number | void;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v9.0+ v9.0+ v9.0+ v9.0+ v9.0+ not supported

Usage notes

After you get the skew angle of an image, you can rotate it with the method Rotate to perform deskewing.


GetImageSize

Syntax

/**
 * Calculate the size in bytes of the specified image assuming it's resized to the given dimensions.
 * @param index Specify the image.
 * @param width Specify the width.
 * @param height Specify the height.
 */
GetImageSize(index: number, width: number, height: number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
all versions all versions all versions all versions all versions not supported

GetImageSizeWithSpecifiedType

Syntax

/**
 * Calculate the size in bytes of the specified image assuming an expected file type.
 * @param index Specify the image.
 * @param type Sepcify the expected file type.
 */
GetImageSizeWithSpecifiedType(index: number, type: Dynamsoft.DWT.EnumDWT_ImageType | number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
all versions all versions all versions all versions all versions not supported

GetSelectedImagesSize

Syntax

/**
 * Calculate the size in bytes of all selected images assuming an expected file type.
 * @param type Sepcify the expected file type.
 */
GetSelectedImagesSize(type: Dynamsoft.DWT.EnumDWT_ImageType | number): number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+ not supported

Usage notes

If the calculation fails, -1 is returned.


GetImagePartURL

Syntax

/**
 * Return the internal URL of the specified image.
 * @param index Specify the image.
 * @param width The width of the image (>150).
 * @param height The height of the image (>150).
 */
GetImagePartURL(index: number, width?: number, height?: number): string;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v14.3.1+ v13.0+ v13.0+ v13.0+ v13.0+ not supported

Usage notes

If width and height are not specified, you get the original image, otherwise you get the image with specified width or height while keeping the same aspect ratio. The returned string is like this ‘dwt://dwt_trial_13000404/img?id=306159652&index=0&t=1502184632022’.


GetImageURL

Syntax

/**
 * Return the direct URL of the specified image.
 * @param index Specify the image.
 * @param width The width of the image (>150).
 * @param height The height of the image (>150).
 */
GetImageURL(index: number, width?: number, height?: number): string;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v12.0+ v12.0+ v12.0+ v12.1+ not supported

Usage notes

The returned URL will be like “https://127.0.0.1:18623/dwt/dwt_17110818/img?id=795151779&index=1&t=1640936181588”.

If width or height is set to -1, you get the original size of image in PNG in Service Mode,or in JPG, PNG(Black&White) in WASM mode, otherwise you get the image with specified width or height while keeping the same aspect ratio.


SelectAllImages

Syntax

/**
 * Select all images and return the indices. Viewer will be scrolled to the last image.
 */
SelectAllImages(): number[];

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.3+ v15.3+ v15.3+ v15.3+ v16.0+

SelectImages

Syntax


/**
 * Select the specified images.
 * @param indices Specify one or multiple images.
 */
SelectImages(indices: number[]): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v16.0+ v16.0+ v16.0+ v16.0+ v16.0+ v16.0+

MoveImage

Syntax

/**
 * Change the position of an image in the buffer.
 * @param from Specify the original position by index.
 * @param to Specify the target position by index.
 */
MoveImage(from: number, to: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

SwitchImage

Syntax

/**
 * Exchange the positions of two images.
 * @param index1 Specify the 1st image.
 * @param index2 Specify the 2nd image.
 */
SwitchImage(index1: number, index2: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v5.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

RemoveImage

Syntax

/**

* Remove the specified image.
* @param index Specify the image.

*/
RemoveImage(index: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

RemoveAllImages

Syntax

/**
 * Remove all images.
 */
RemoveAllImages(): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

RemoveAllSelectedImages

Syntax

/**
 * Remove all selected images.
 */
RemoveAllSelectedImages(): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

CurrentImageIndexInBuffer

Syntax

/**
 * Return the index of the current image in the buffer or set the image specified by index as the current image.
 */
CurrentImageIndexInBuffer: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v16.0+

HowManyImagesInBuffer

Syntax

/**
 * Return how many images are held in the buffer
 */
readonly HowManyImagesInBuffer: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v16.0+

MaxImagesInBuffer

Syntax

/**
 * Return or set how many images can be held in the buffer.
 */
MaxImagesInBuffer: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v16.0+

Usage notes

When acquiring images and the number of images goes beyond the value set to MaxImagesInBuffer , new images will replace old images starting from the 1st one.


SelectedImagesIndices

Syntax

/**
 * Return the indices of the selected images.
 */
readonly SelectedImagesIndices: number[];

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v16.0+ v16.0+ v16.0+ v16.0+ v16.0+ v16.0+

SelectionRectAspectRatio

Syntax

/**
 * Specify a aspect ratio to be used when selecting a rectangle on an image.
 */
SelectionRectAspectRatio: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v10.0+ v10.0+ v11.0+ v11.0+ v12.1+ v16.0+

BlankImageCurrentStdDev

Syntax

/**
 * Return the deviation of the pixels in the current image.
 */
readonly BlankImageCurrentStdDev: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v8.0+ v8.0+ v8.0+ v8.0+ v8.0+ not supported

Usage notes

This property is only valid after IsBlankImageExpress is called.


BlankImageMaxStdDev

Syntax

/**
 * Return or set the maximum deviation of the pixels in an image which is used to determine whether the image is blank.
 */
BlankImageMaxStdDev: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+ not supported

Usage notes

[0, 100] is the interval of allowed values, inclusive. 0 gives a single-color image. The default value is 1.

This property is only valid after IsBlankImageExpress is called.


BlankImageThreshold

Syntax

/**
 * Returns or sets the dividing line between black and white.
 */
BlankImageThreshold: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+ not supported

Usage notes

[0, 255] is the interval of allowed values, inclusive. The default value is 128. This property is only valid after IsBlankImageExpress is called.


BufferMemoryLimit

Syntax

/**
 * Return or set how much physical memory is allowed for storing images currently
 * loaded in Dynamic Web TWAIN. Once the limit is reached, images will be cached on the hard disk.
 */
BufferMemoryLimit: number;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v10.1+ v10.1+ v10.1+ v11.0+ v12.1+ v16.0+

Usage notes

Set this property only when you have a very small physical memory (< 2GB) or a very big one (>4GB). The more memory is allowed, the better the performance will be. The default value is set to 800 (MB), anything beyond 800MB gets compressed, encrypted and cached on the local disk.

All cached data is encrypted and can only be read by Dynamic Web TWAIN and it will be destroyed when it is no longer used.


IsBlankImage

Syntax

/**
 * Check whether the specified image is blank.
 * @param index Specify the image.
 */
IsBlankImage(index: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+ not supported

IsBlankImageExpress

Syntax

/**
 * Check whether the specified image is blank.
 * @param index Specify the image.
 */
IsBlankImageExpress(index: number): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v10.0+ v10.0+ v10.0+ v10.0+ v10.0+ not supported

Usage notes

IsBlankImage is more accurate than IsBlankImageExpress but it works slower.

BlankImageCurrentStdDev should be read after either IsBlankImage() or IsBlankImageExpress .

If you believe an image should be blank but IsBlankImage() or IsBlankImageExpress is returning false , you can read BlankImageCurrentStdDev for that image and then set a bigger value to BlankImageMaxStdDev .

Both BlankImageCurrentStdDev and BlankImageMaxStdDev range from 0 to 100.


IfAllowLocalCache

Syntax

/**
 * Return or set whether the feature of disk caching is enabled.
 */
IfAllowLocalCache: boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v10.0+ v10.0+ v10.0+ v11.0+ v12.1+ not supported

Usage notes

The default value of IfAllowLocalCache is true. When the property is true, you can scan as many images as you want as long as you have a big enough disk.
The default threshold is set to 800 (MB), anything beyond 800MB gets compressed, encrypted and cached on the local disk.
If neccessary, you can set the threshold using BufferMemoryLimit for better performance.
All cached data is encrypted and can only be read by Dynamic Web TWAIN and it will be destroyed when it is no longer used.


OnBufferChanged

Syntax

/**
 * An enhanced callback triggered when a change occurs in the buffer.
 * @argument bufferChangeInfo Details about the buffer change.
 */
RegisterEvent('OnBufferChanged',
    function (bufferChangeInfo: BufferChangeInfo) {}
): boolean;

interface BufferChangeInfo {
    /**
     * Action type includes 'add', 'remove', 'modify', 'shift' and 'filter'
     */
    action: string;
    /**
     * The image id (not the index) of the current page.
     */
    currentId: number;
    /**
     * All image ids.
     */
    imageIds: number[];
    /**
     * All selected image ids.
     */
    selectedIds: number[];
}

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v16.2+ v16.2+ v16.2+ v16.2+ not supported

Usage notes

Action types include

  • add: New pages are added to the buffer.
  • remove: The existing pages are removed.
  • modify: The existing pages are modified.
  • shift: The existing pages are reordered.
  • filter: The existing pages are filtered by a tag.

OnBitmapChanged

Syntax

/**
 * A built-in callback triggered when the current image in buffer is changed like flipped, cropped, rotated, etc. or a new image has been acquired.
 * @argument indexString Array of the changed index(indices).
 * @argument type Operation type.
   1 means new image(s) were added at the tail,
   2 means image(s) were inserted before the current index,
   3 means image(s) are deleted,
   4 means image(s) are modified,
 * @argument index Index of the current image.
 */
RegisterEvent('OnBitmapChanged',
    function (
        indexString: number[],
        type: number,
        index: number
    ) {}
): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v8.0+ v10.0+ v10.0+ v11.0+ v12.1+ v16.0+

Example

DWObject.RegisterEvent(
  "OnBitmapChanged",
  function (strUpdatedIndex, operationType, sCurrentIndex) {
    console.log("Image " + sCurrentIndex + " has changed!");
  }
);

OnTopImageInTheViewChanged

Syntax

/**
 * A built-in callback triggered when the top index currently displayed in the viewer changes.
 * @argument index Index of the current image.
 */
RegisterEvent('OnTopImageInTheViewChanged',
    function (index: number) {}
): boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
v5.1+ v10.1+ v11.0+ v11.0+ v12.1+ v16.0+

Usage notes

This API does not work if the view mode of the viewer is set to -1 by -1.


OnIndexChangeDragDropDone

Syntax

/**
 * A built-in callback triggered when images in the buffer are dragged to new positions.
 * @argument indexPairs The list of index changes.
 */
RegisterEvent('OnIndexChangeDragDropDone',
    function (indexPairs: Pair[]) {}
): boolean;

Pair: [from: number, to: number];

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v15.0+ v15.0+ v15.0+ v15.0+ v16.0+

GetTagListByIndex

Syntax

/**
 * Return the tag(s) of a specified image.
 * @argument index Index of the image.
 */
GetTagListByIndex(index: number):string[]

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

Example

DWObject.GetTagListByIndex(0);

CreateFile

Syntax

/**
 * Create a category for the scanned image(s).
 * @argument categoryName Specify the category name.
 */
CreateFile(categoryName:string):Boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

Example

//Store the scanned image(s) under 'Category1'.
DWObject.CreateFile("Category1");
DWObject.OpenFile("Category1"); //Need to call OpenFile after CreateFile.
DWObject.AcquireImage(successCallback, failureCallback);

function successCallback() {
  console.log("successful");
}

function failureCallback(errorCode, errorString) {
  alert(errorString);
}

Usage notes

  1. If the documents are already sorted before scanning, you can use CreateFile, OpenFile to group the documents.
  2. If the documents are not already sorted before scanning and you want to first scan, then sort, you can use tags to manage that. Relevant APIs: SetDefaultTag, TagImages, GetTagList, FilterImagesByTag

OpenFile

Syntax

/**
 * Use the specified category for the scanned image(s)
 * @argument categoryName Specify the category name.
 */
OpenFile(categoryName:string):Boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

Example

//Stored the scanned image(s) under 'Category2'.
DWObject.CreateFile("Category1");
DWObject.CreateFile("Category2");
DWObject.CreateFile("Category3");
DWObject.OpenFile("Category2"); //Need to call OpenFile after CreateFile.
DWObject.AcquireImage(successCallback, failureCallback);

function successCallback() {
  console.log("successful");
}

function failureCallback(errorCode, errorString) {
  alert(errorString);
}

GetCurrentFileName

Syntax

/**
 * Get the current category name. The default value is 'dynamsoft-dvs-file'. Scanned image(s) are stored in this category by default if no category name is created.
 */
GetCurrentFileName():String;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

RemoveFile

Syntax

/**
 * Delete the specified category and all images in it.
 * @argument categoryName Specify the category name.
 */
RemoveFile(categoryName:string):Boolean;

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

GetFileInfoList

Syntax

/**
 * Get the list of all categories and their information.
 */
GetFileInfoList():Json

Json:
[{
   name: "categoryName",
   imageIds:[23122335, 25566822323]
},
{……}]

Availability

Desktop Service Edition WebAssembly Edition
ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) WASM
not supported v17.2+ v17.2+ v17.2+ v17.2+ v17.2+

Is this page helpful?

YesYes NoNo

In this article:

latest version

  • Latest Version
  • Version 17.1.1
  • Version 17.0
  • Version 16.2
  • Version 16.1.1
Change +
© 2003–2022 Dynamsoft. All rights reserved.
Privacy Statement / Site Map / Home / Purchase / Support