Web Demos

BARCODE READER SDK DEMO

Explore the flexibe barcode reading settings to optimize for your specific usage scenario.

WEB TWAIN SDK DEMO

Try the most popular web scanner features: scan images, import local images and PDF files, edit, save to local, upload to database, and etc.

BARCODE READER JAVASCRIPT DEMO

Transform any camera-equipped devices into real-time, browser-based barcode and QR code scanners.

MRZ SCANNER WEB DEMO

Detects the machine-readable zone of a passport, scans the text, and parses into human-readable data.

APP STORE DEMOS

BARCODE READER SDK FOR IOS

BARCODE READER SDK FOR ANDROID

VIEW MORE DEMOS >
Dev Center
Table of contents

{WebTwainObject} Buffer Manage

{WebTwainObject} denotes the WebTwain instance.

Methods

Properties

Events


IndexToImageID

Syntax

/**

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

*/
IndexToImageID(index: number): number;

ImageIDToIndex

Syntax

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

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.

ClearImageTags

Syntax

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

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;

SetDefaultTag

Syntax

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

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;

GetImageBitDepth

Syntax

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

GetImageHeight

Syntax

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

GetImageWidth

Syntax

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

GetImageXResolution

Syntax

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

GetImageYResolution

Syntax

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

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;

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;

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;

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.EnumDWT_ImageType | number): number;

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.EnumDWT_ImageType | number): number;

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;

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;

Usage notes

If width or height is set to -1, you get the original image, otherwise you get the image with specified width or height while keeping the same aspect ratio.


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;

HowManyImagesInBuffer

Syntax

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

MaxImagesInBuffer

Syntax

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

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[];

SelectAllImages

Syntax

/**
 * Select all images and return the indices.
 */
SelectAllImages(): number[];

SelectImages

Syntax


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

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;

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;

RemoveImage

Syntax

/**

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

*/
RemoveImage(index: number): boolean;

RemoveAllImages

Syntax

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

RemoveAllSelectedImages

Syntax

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

SelectionRectAspectRatio

Syntax

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

BlankImageCurrentStdDev

Syntax

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

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;

BlankImageThreshold

Syntax

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

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;

IsBlankImage

Syntax

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

IsBlankImageExpress

Syntax

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

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;

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.


OnBitmapChanged

Syntax

/**
 * A built-in callback triggered when a change occurs in the buffer.
 * @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; 

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; 

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];

Is this page helpful?

YesYes NoNo

In this article:

version 16.1.1

  • Latest Version
  • Version 17.2.1
  • 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