VintaSoft Twain .NET SDK v10.3
Vintasoft.Twain Namespace / WebTwainDeviceJS type / setCapability Method
Integer value of device capability identifier OR WebDeviceCapabilityIdEnumJS object.
New capability value.
Function that will be executed if request is executed successfully.
Here is function prototype "function __success(data)".
The data parameter has the following properties:
Function that will be executed if request is failed.
Here is function prototype "function __error(data)".
The data parameter can be:
  1. An object with following properties:
    • errorMessage (string): Error message.
    • blocked (boolean): Indicates that the requested action is blocked by another request.
    if exception is catched inside web service.
  2. Otherwise, jqXHR object.
In This Topic
    setCapability Method
    In This Topic
    Sends an asynchronous request to a server for setting the TWAIN device capability.
    Syntax
    var instance = new Vintasoft.Twain.WebTwainDeviceJS(deviceName,
                                                       productFamily,
                                                       manufacturer,
                                                       driverVersion,
                                                       twainVersion,
                                                       deviceManager);
    var value; // Type: any
    
    // Parameters
    var twainCapabilityId; // Type:  object
    var twainCapabilityValue; // Type:  string
    var successFunc; // Type:  object
    var errorFunc; // Type:  object
    
    value = instance.setCapability(twainCapabilityId, twainCapabilityValue, successFunc, errorFunc);
    function setCapability( 
       twainCapabilityId : object,
       twainCapabilityValue : string,
       successFunc : object,
       errorFunc : object
    ) : any;

    Parameters

    twainCapabilityId
    Integer value of device capability identifier OR WebDeviceCapabilityIdEnumJS object.
    twainCapabilityValue
    New capability value.
    successFunc
    Function that will be executed if request is executed successfully.
    Here is function prototype "function __success(data)".
    The data parameter has the following properties:
    • capability (object): The value of TWAIN device capability.
      Twain device capability is object with the following properties:
      • id (number): The identifier of TWAIN device capability.
      • name (string): The name of TWAIN device capability.
      • value (object): The value (was obtained using the Get mode) of TWAIN device capability.
        Value of TWAIN device capability is object with the following properties:
        • containerType (object): Instance of WebTwainValueContainerTypeEnumJS class that represents the container type of TWAIN device capability value.
        • valueType (object): Instance of WebTwainValueTypeEnumJS class that represents the type of TWAIN device capability value.
        • value (object): The current value of TWAIN device capability value.
        • defaultValue (object): The default value of TWAIN device capability value.
        • minValue (number): The minimum value of TWAIN device capability value.
        • maxValue (number): The maximum value of TWAIN device capability value.
        • stepSize (number): The step size of TWAIN device capability value.
        • supportedValues (object): The supported values of TWAIN device capability value.
      • currentValue (object): The curent value (was obtained using the GetCurrent mode) of TWAIN device capability.
      • defaultValue (object): The default value (was obtained using the GetDefault mode) of TWAIN device capability.
    errorFunc
    Function that will be executed if request is failed.
    Here is function prototype "function __error(data)".
    The data parameter can be:
    1. An object with following properties:
      • errorMessage (string): Error message.
      • blocked (boolean): Indicates that the requested action is blocked by another request.
      if exception is catched inside web service.
    2. Otherwise, jqXHR object.
    Exceptions
    ExceptionDescription
    Thrown if arguments have wrong types.
    Thrown if device is not opened.
    Example
    // This function shows how to change page size of opened TWAIN device.
    function setPageSize(openedDevice, pageSizeValue, successFunc, errorFunc) {
        // send request
        openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("ISupportedSizes"), pageSizeValue, successFunc, errorFunc);
    }
    
                 * 
    // This function shows how to change image layout of opened TWAIN device.
    function setImageLayout(openedDevice, left, top, width, height, successFunc, errorFunc) {
        // create capabilty value
        var imageLayoutValue = left + "," + top + "," + width + "," + height;
        // send request
        openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("IFrames"), imageLayoutValue, successFunc, errorFunc);
    }
    
                 * // This function shows how to change unit of measure and resolution of opened TWAIN device.
    function setUnitOfMeasureAndResolution(openedDevice, unitOfMeasure, resX, resY) {
        // success callback
        function __success(data) {
            // capability
            var capability = data.capability;
            // new value of capability
            var newValue = capability.currentValue.value;
            // log information about new value
            console.log("Capability '" + capability.name + "' new value - " + newValue);
        }
    
        // error callback
        function __error(data) {
            // message
            var message = "";
            // if capability exists
            if (data.capability != undefined)
                // add information about capability name
                message += "Capability '" + data.capability.name + "':";
            // add information about error
            message += data.errorMessage;
            // show message
            alert(message);
        }
    
        // change unit of measure
        openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("IUnits"), unitOfMeasure, __success, __error);
        // change horizontal resolution
        openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("IXResolution"), resX, __success, __error);
        // change vertical resolution
        openedDevice.setCapability(new Vintasoft.Twain.WebDeviceCapabilityIdEnumJS("IYResolution"), resY, __success, __error);
    }
    Browser Compatibility
    9
    5
    15
    5
    See Also