AcquireImage

Description

Starts image acquisition.

Support information

Syntax

.AcquireImage([optionalDeviceConfig], [optionalAsyncSuccessFunc, optionalAsyncFailureFunc]);

Parameters

optional optionalDeviceConfig A JS object used to set up the device for image acquisition.

<OnSuccess function> optional optionalAsyncSuccessFunc: callback function triggered when acquiring image succeeds.
<OnFailure function> optional optionalAsyncFailureFunc: callback function triggered when acquiring image fails.

Please refer to the function prototype OnSuccess or OnFailure.

The callback functions are only available for the HTML5 edition.
As the parameters are all optional, there are 4 ways for you to use this method. Please check out the following info and the examples at the bottom of this manual for more details.

//The following 2 options don't invoke the callback functions.
DWObject.AcquireImage();
DWObject.AcquireImage(DeviceConfig);

//The following 2 options invoke the callback functions.
DWObject.AcquireImage(AsyncSuccessFunc, AsyncFailureFunc);
DWObject.AcquireImage(DeviceConfig, AsyncSuccessFunc, AsyncFailureFunc);

Return value

bool

true indicates success. false indicates failure.

When false is returned, check ErrorCode or ErrorString for error information.

Remarks

This method does the same thing as EnableSource().
The purpose of providing this method is to enable users to handle TWAIN-compliant image acquisition device without knowing the terms used in TWAIN specification.

The method returns as soon as the scanning starts. In other words, it's an asynchronous method.

Example

//Callback functions for AcquireImage, only valid in version 11.3 and above
function OnSuccess() {
    console.log('successful');
}

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

//Traditional way to start the acquisition      
function Acquire_onclick() {
    DWObject.SelectSource();  
    DWObject.OpenSource();     
    DWObject.IfShowUI = false;
    DWObject.PixelType = 2;
    DWObject.Resolution = 200;
    DWObject.IfFeederEnabled = true;
    DWObject.IfDuplexEnabled = false;
    DWObject.IfDisableSourceAfterAcquire = true;
    
    //Invokes the method with the callback functions.     
    DWObject.AcquireImage(OnSuccess, OnFailure);
}
//Use the optional parameter to set up the acquisition, only valid in version 10 and above
function Acquire_onclick() {
    DWObject.SelectSource();  
    DWObject.OpenSource();     
    var _obj = {};
            _obj.IfShowUI = false;
            _obj.PixelType = 2;
            _obj.Resolution = 200;
            _obj.IfFeederEnabled = true;
            _obj.IfDuplexEnabled = false;
            _obj.IfDisableSourceAfterAcquire = true;        
    DWObject.AcquireImage(_obj);
}

See also

EnableSource()