Scanning with ABBYY FlexiCapture SDK
ABBYY FlexiCapture SDK offers a ScanManager object for managing the scanning sources. The ScanSourcesEx property of this object provides access to the list of all available scanners, while the FindScanSources method allows you to select the scanners by API type they provide and the user interface type you wish to use to set scanning options.
To scan and save the files to disk you can use either of these two methods of the ScanSource object: Scan method, which does not return until the scanning is complete, and BeginScan method, which starts the asynchronous scanning operation and returns immediately.
You can implement the IScanCallback interface and use it to get notifications about the progress of scanning.
The following parameters are accessible via the ABBYY FlexiCapture 12 SDK API: brightness, color, resolution, image compression type, image rotation angle, the size of the scanning area, duplex scanning mode, automatic feeder mode, a pause between pages and some more. The scanning parameters are set by using the ScanSettings property of the ScanSource object. This property is required to get access to the ScanSourceSettings object which, in its turn, provides access to the scanning settings of a source.
You can find some useful recommendations as to the preferable scanning options in the Tips for Document Scanning section.
To scan the images synchronously:
- Create a ScanManager object using the CreateScanManager method of the Engine object.
- Select the scanning source using the FindScanSources method of the ScanManager object, specifying the API and UI type that should be supported by the scanner.
- If you choose to display no dialog box for the user to set scanning options him- or herself, tune the scanning options using the ScanSettings property of the chosen ScanSource. Select the appropriate values for brightness, resolution, and the other parameters in the corresponding properties of the ScanSourceSettings object. You can check which settings are available for this scanner using the Capabilities property of the ScanSource.
- Create or choose an existing folder in which scanned pages will be stored. Put the folder name into a BSTR variable, for example, ScanFolder.
- Call the Scan method of the ScanSource object, providing as the parameter the type of dialog box to be shown to the user (pass SOIT_None constant to display no box), and the ScanFolder path to the folder with the results.
- The image file names will be returned by this method as a StringsCollection object. You can get the image file names from this StringsCollection object and then process the files as usual.
To scan the images asynchronously:
- Create an object implementing the IScanCallback interface. In case of asynchronous scanning operation, notifications from callback interface are very useful.
- Create a ScanManager object using the CreateScanManager method.
- Select the scanning source using the FindScanSources method of the ScanManager object, specifying the API and UI type that should be supported by the scanner.
- If you choose to display no dialog box for the user to set scanning options him- or herself, tune the scanning options using the ScanSettings property of the chosen ScanSource. Select the appropriate values for brightness, resolution, and the other parameters in the corresponding properties of the ScanSourceSettings object. You can check which settings are available for this scanner using the Capabilities property of the ScanSource.
- Create or choose an existing folder in which scanned pages will be stored. Put the folder name into a BSTR variable, for example, ScanFolder.
- Call the BeginScan method of the ScanSource object, providing as the parameter the type of dialog box to be shown to the user (pass SOIT_None constant to display no box), and the ScanFolder path to the folder with the results. You also need to pass the pointer to the callback object you created.
- The path to image file is returned with the OnImageScanned notification of the IScanCallback interface, and the completion of the operation is signalled by the OnScanComplete notification. As you are providing the implementation for these methods, you can choose what to do in each of these situations.
Important! Until the scanning is completed and the OnScanComplete notification received, you cannot run BeginScan or Scan again, even for some other scanner. The advantage of asynchronous scanning is not that you can perform several scanning operations at once, but that you can process the images you already received while the new images are being scanned.
See also
8/15/2023 1:19:30 PM