ImageGear .NET
Scanner Selection

A scanner must first be selected by calling the ImGearIsisScannerSession setScanner method in order for the ImGearIsisScannerSession scan method to work or any of the ImGearIsisScanner methods to work. When a scanner is selected, the ImGearIsisScanner selected property returns true. A scanner can be unloaded by calling the unload method.

The setScanner method has two overloads. You can specify a load option for a scanner selection dialog or to specify that the currently selected scanner should be used. This is demonstrated below:

JavaScript Example
Copy Code
            function onScannerLoaded(status) {
                if (status.get_status() !== ImageGear.Web.Isis.ImGearIsisStatus.Completed) {
                    alert(status.get_statusMessage());
                }
                // The scanner can now be accessed through the ImGearIsisScannerSession scanner property.
                var scanner = scannerSession.get_scanner();
                // You could use the getTag method or getAllTags method here
                // to get the current scanner settings.
            }
            // Show the scanner selection dialog with a list of connected drivers.
            scannerSession.setScannerWithDialog(
                ImageGear.Web.Isis.ImGearIsisLoadScannerOption.ShowConnectedDriverList, onScannerLoaded);

Another option is to pass an ImGearIsisScanner object to change to the specified scanner without showing a dialog. You can get a collection of connected scanners and a collection of undetected scanners by calling the ImGearIsisScannerSession getScanners method. This is demonstrated below, where “scannerSelect” is an HTML DOM <select> object:

JavaScript Example
Copy Code
       var scanners;
...
       function ButtonGetScanners_onclick() {
           function getScannersCallback(connectedDevices, undetectedDevices, status) {
               if (status.get_status() !== ImageGear.Web.Isis.ImGearIsisStatus.Completed) {
                   alert(status.get_statusMessage());
               }
               var select = document.getElementById('scannerSelect');              
               // Store the scanners so one of them can be set later.
               scanners = connectedDevices;

               for (var i = 0; i < connectedDevices.get_length(); i++) {
                   var scanner = connectedDevices.getScanner(i);
                  
                   var option = document.createElement(‘option’);
                   var scannerName = scanner.get_name();
                   option.text = scannerName;
                   select.add(option, null);
               }
            }
            // Get a list of connected scanners and add each to a list box.
            var operationStatus = scannerSession.getScanners(getScannersCallback);
       }
       function ButtonSetConnectedScanner_onclick() {
           function onScannerLoaded(status) {
               if (status.get_status() !== ImageGear.Web.Isis.ImGearIsisStatus.Completed) {
                   alert(status.get_statusMessage());
               }
                // The scanner can now be accessed through the ImGearIsisScannerSession scanner property.
                var scanner = scannerSession.get_scanner();
                // You could use the getTag method or getAllTags method here
                // to get the current scanner settings.
           }
           var select = document.getElementById('scannerSelect');
           var selectedScanner = scanners.getScanner(select.selectedIndex);
           // Set the scanner that is selected in the connected list.
           scannerSession.setScanner(selectedScanner, onScannerLoaded);
       }

 

 

 


©2017. Accusoft Corporation. All Rights Reserved.

Send Feedback