VintaSoft Twain .NET SDK 15.0: Documentation for Web developer
In This Topic
    A list of TWAIN/SANE devices
    In This Topic
    TWAIN/SANE device manager allows to get a list of TWAIN and SANE devices programmatically. The device list can be obtained using the WebTwainDeviceManagerJS.get_Devices function. Information about the default TWAIN device can be obtained using the WebTwainDeviceManagerJS.get_DefaultDevice function. Information about the opened device can be obtained using the WebTwainDeviceManagerJS.get_OpenedDevice function.


    Here is JavaScript code that demonstrates how to get information about all TWAIN and SANE devices installed in the system:
    // get information about TWAIN and SANE devices installed in the system
    __getInfoAboutTwainDevices();
    
    
    
    /**
     * Returns information about TWAIN and SANE devices installed in the system.
     */
    function __getInfoAboutTwainDevices() {
        // register the evaluation version of VintaSoft Web TWAIN service
        // please read how to get evaluation license in documentation: https://www.vintasoft.com/docs/vstwain-dotnet-web/Licensing-Twain_Web-Evaluation.html
        Vintasoft.Twain.WebTwainGlobalSettingsJS.register('REG_USER', 'REG_URL', 'REG_CODE', 'EXPIRATION_DATE');
    
        // URL to the VintaSoft Web TWAIN service
        var serviceUrl = 'https://localhost:25329/api/VintasoftTwainApi';
        // a Web API controller that allows to work with TWAIN and SANE devices
        var twainService = new Vintasoft.Shared.WebServiceControllerJS(serviceUrl);
    
        // TWAIN/SANE device manager
        var deviceManager = new Vintasoft.Twain.WebTwainDeviceManagerJS(twainService);
    
        // the default settings of device manager
        var deviceManagerInitSetting = new Vintasoft.Twain.WebTwainDeviceManagerInitSettingsJS();
    
        try {
            // open device manager
            deviceManager.open(deviceManagerInitSetting);
    
            // get TWAIN and SANE devices installed in the system
            var devices = deviceManager.get_Devices();
            for (var i = 0; i < devices.length; i++) {
                // output the device name
                console.log('Device ' + devices[i].get_DeviceName());
            }
        }
        catch (ex) {
            alert(ex);
        }
        finally {
            // close the device manager
            deviceManager.close();
        }
    }
    
    


    Here is TypeScript code that demonstrates how to get information about all TWAIN and SANE devices installed in the system:
    import { Component } from '@angular/core';
    
    @Component({
      selector: 'twain-scanning-demo',
      templateUrl: './twain-scanning-demo.component.html'
    })
    export class TwainScanningDemoComponent {
    
      ngOnInit() {
        // get information about TWAIN and SANE devices installed in the system
        this.__getInfoAboutTwainDevices();
      }
    
    
      /**
       * Returns information about TWAIN and SANE devices installed in the system.
       */
      __getInfoAboutTwainDevices() {
        // register the evaluation version of VintaSoft Web TWAIN service
        // please read how to get evaluation license in documentation: https://www.vintasoft.com/docs/vstwain-dotnet-web/Licensing-Twain_Web-Evaluation.html
        Vintasoft.Twain.WebTwainGlobalSettingsJS.register('REG_USER', 'REG_URL', 'REG_CODE', 'EXPIRATION_DATE');
    
        // URL to the VintaSoft Web TWAIN service
        let serviceUrl: string = 'https://localhost:25329/api/VintasoftTwainApi';
        // a Web API controller that allows to work with TWAIN and SANE devices
        let twainService: Vintasoft.Shared.WebServiceControllerJS = new Vintasoft.Shared.WebServiceControllerJS(serviceUrl);
    
        // TWAIN/SANE device manager
        let deviceManager: Vintasoft.Twain.WebTwainDeviceManagerJS = new Vintasoft.Twain.WebTwainDeviceManagerJS(twainService);
    
        // the default settings of device manager
        let deviceManagerInitSetting: Vintasoft.Twain.WebTwainDeviceManagerInitSettingsJS = new Vintasoft.Twain.WebTwainDeviceManagerInitSettingsJS();
    
        try {
          // open device manager
          deviceManager.open(deviceManagerInitSetting);
        }
        catch (ex) {
          alert(ex);
          return;
        }
    
        try {
          // get TWAIN and SANE devices installed in the system
          let devices: Vintasoft.Twain.WebTwainDeviceJS[] = deviceManager.get_Devices();
          for (let i: number = 0; i < devices.length; i++) {
            // output the device name
            console.log('Device ' + devices[i].get_DeviceName());
          }
        }
        catch (ex) {
          alert(ex);
        }
        finally {
          // close the device manager
          deviceManager.close();
        }
      }
    
    }