VintaSoft Twain .NET SDK 15.4: Документация для Веб разработчика
В этом разделе
Список TWAIN/WIA/SANE/eSCL устройств
В этом разделе
Менеджер устройств TWAIN/WIA/SANE/eSCL позволяет получить список TWAIN/WIA/SANE/eSCL устройств программным путем. Список TWAIN/WIA/SANE/eSCL устройств можно получить с помощью функции WebTwainDeviceManagerJS.get_Devices. Информацию об TWAIN/WIA/SANE/eSCL устройстве по умолчанию можно получить с помощью функции WebTwainDeviceManagerJS.get_DefaultDevice. Информацию об открытом TWAIN/WIA/SANE/eSCL устройстве можно получить с помощью функции WebTwainDeviceManagerJS.get_OpenedDevice.

Вот JavaScript код, который демонстрирует как получить информацию обо всех TWAIN/WIA/SANE/eSCL устройствах, которые доступны в системе:
// get information about TWAIN/WIA/SANE/eSCL devices installed in the system
__getInfoAboutTwainDevices();



/**
 * Returns information about TWAIN/WIA/SANE/eSCL 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.ru/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/WIA/SANE/eSCL devices
    var twainService = new Vintasoft.Shared.WebServiceControllerJS(serviceUrl);

    // TWAIN/WIA/SANE/eSCL 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/WIA/SANE/eSCL 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();
    }
}



Вот TypeScript код, который демонстрирует как получить информацию обо всех TWAIN/WIA/SANE/eSCL устройствах, которые доступны в системе:
import { Component } from '@angular/core';

@Component({
  selector: 'twain-scanning-demo',
  templateUrl: './twain-scanning-demo.component.html'
})
export class TwainScanningDemoComponent {

  ngOnInit() {
    // get information about TWAIN/WIA/SANE/eSCL devices installed in the system
    this.__getInfoAboutTwainDevices();
  }


  /**
   * Returns information about TWAIN/WIA/SANE/eSCL 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.ru/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/WIA/SANE/eSCL devices
    let twainService: Vintasoft.Shared.WebServiceControllerJS = new Vintasoft.Shared.WebServiceControllerJS(serviceUrl);

    // TWAIN/WIA/SANE/eSCL 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/WIA/SANE/eSCL 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();
    }
  }

}