getCapabilityAsync(Vintasoft.Twain.WebDeviceCapabilityIdEnumJS,number,function,function) Method
In This Topic
Sends an asynchronous request to get value of TWAIN device capability.
Syntax
var instance = new Vintasoft.Twain.WebTwainDeviceJS(deviceName, productFamily, manufacturer, driverVersion, twainVersion, deviceManager, is64Bit);
var value; // Type: any
// Parameters
var twainCapabilityId; // Type: WebDeviceCapabilityIdEnumJS
var usageMode; // Type: number
var successFunc; // Type: function
var errorFunc; // Type: function
value = instance.getCapabilityAsync(twainCapabilityId, usageMode, successFunc, errorFunc);
function getCapabilityAsync(
: WebDeviceCapabilityIdEnumJS,
: number,
: Function,
: Function
) : any;
Parameters
- twainCapabilityId
- An instance of WebDeviceCapabilityIdEnumJS class that defines identifier of TWAIN device capability.
- usageMode
- An integer value, which defines usage mode of device capability.
- successFunc
- A function that will be executed if request is executed successfully. Function prototype: "successFunc(twainDevice, capInfos)", where 'twainDevice' parameter is an instance of WebTwainDeviceJS class, 'capInfo' parameter is an array that contains information about TWAIN device capability.
- errorFunc
- A function that will be executed if request is failed. Function prototype: "errorFunc(twainDevice, errorMessage)", where 'twainDevice' parameter is an instance of WebTwainDeviceJS class, 'errorMessage' parameter is string that describes error.
Exceptions
Exception | Description |
| Thrown if argument has wrong type OR device is not opened OR error occurs during getting information about supported device capabilities. |
Remarks
This function sends an asynchronous request to get information about TWAIN device capability. If you want to use synchronous request instead of asynchronous request, please use WebTwainDeviceJS.getCapability function.
Example
// Returns information about supported pixel types for opened TWAIN device.
function getSupportedPixelTypes(twainDevice) {
try {
// specify that we need to get information about IPixelType capability
var pixelTypeCap = new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("IPixelType");
// specify that we need to get value of TWAIN device capability
var capUsageModeId = 1;
// send an asynchronous request to get supported values for IPixelType capability
twainDevice.getCapabilityAsync(pixelTypeCap, capUsageModeId, __twainDevice_getCapabilityAsync_success, __twainDevice_getCapabilityAsync_error);
}
catch (ex) {
alert(ex);
}
}
function __twainDevice_getCapabilityAsync_success(twainDevice, capInfos) {
// get an instance of WebTwainCapabilitySupportedValuesJS class that contains information about supported values of IPixelType capability
var supportedValues = twainCapInfo.get_SupportedValues();
// get an array with supported values of IPixelType capability
var supportedValuesArray = supportedValues.get_SupportedValuesAsArray();
// output supported pixel types to the console
var consoleString = "Supported pixel types: ";
for (var i = 0; i < supportedValuesArray.length; i++) {
consoleString += supportedValuesArray[i].toString() + ' ';
}
console.log(consoleString);
}
function __twainDevice_getCapabilityAsync_error(twainDevice, errorMessage) {
alert(errorMessage);
}
Browser Compatibility
See Also