ImageScanner
ImageScanner
ImageScanner
ImageScanner
Class
Definition
Represents the properties of images to scan.
public : sealed class ImageScanner : IImageScannerpublic sealed class ImageScanner : IImageScannerPublic NotInheritable Class ImageScanner Implements IImageScanner// You can use this class in JavaScript.
- Attributes
| Device family |
Windows Desktop Extension SDK (introduced v10.0.10240.0)
|
| API contract |
Windows.Devices.Scanners.ScannerDeviceContract (introduced v1)
|
Properties
AutoConfiguration AutoConfiguration AutoConfiguration AutoConfiguration
Gets and sets the scan settings of the auto-configured scan unit, like the file format, including compression to deliver the scanned data in. This property is ignored if the scanner is not capable of auto-configuration.
public : ImageScannerAutoConfiguration AutoConfiguration { get; }public ImageScannerAutoConfiguration AutoConfiguration { get; }Public ReadOnly Property AutoConfiguration As ImageScannerAutoConfiguration// You can use this property in JavaScript.
- Value
- ImageScannerAutoConfiguration ImageScannerAutoConfiguration ImageScannerAutoConfiguration ImageScannerAutoConfiguration
The scan configuration. Null if the scanner is not capable of auto-configuration.
DefaultScanSource DefaultScanSource DefaultScanSource DefaultScanSource
Gets the default scan source chosen for this scanner device.
public : ImageScannerScanSource DefaultScanSource { get; }public ImageScannerScanSource DefaultScanSource { get; }Public ReadOnly Property DefaultScanSource As ImageScannerScanSource// You can use this property in JavaScript.
The type of scan source.
Remarks
By default, the scan source will be selected from the device in this order of priority:
- Auto
- Flatbed
- Feeder
DeviceId DeviceId DeviceId DeviceId
Gets the PnP device identifier of this scanner device.
public : PlatForm::String DeviceId { get; }public string DeviceId { get; }Public ReadOnly Property DeviceId As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The PnP device identifier.
FeederConfiguration FeederConfiguration FeederConfiguration FeederConfiguration
Gets or sets the scan settings of the Feeder scan unit, like page size, orientation, and scan resolution.
public : ImageScannerFeederConfiguration FeederConfiguration { get; }public ImageScannerFeederConfiguration FeederConfiguration { get; }Public ReadOnly Property FeederConfiguration As ImageScannerFeederConfiguration// You can use this property in JavaScript.
- Value
- ImageScannerFeederConfiguration ImageScannerFeederConfiguration ImageScannerFeederConfiguration ImageScannerFeederConfiguration
The scanner's Feeder configuration. Null if there is no Feeder.
FlatbedConfiguration FlatbedConfiguration FlatbedConfiguration FlatbedConfiguration
Gets and sets the scan settings of the Flatbed scan unit, like scan resolution and color mode.
public : ImageScannerFlatbedConfiguration FlatbedConfiguration { get; }public ImageScannerFlatbedConfiguration FlatbedConfiguration { get; }Public ReadOnly Property FlatbedConfiguration As ImageScannerFlatbedConfiguration// You can use this property in JavaScript.
- Value
- ImageScannerFlatbedConfiguration ImageScannerFlatbedConfiguration ImageScannerFlatbedConfiguration ImageScannerFlatbedConfiguration
The scan configuration of the scanner's Flatbed. Null if there is no Flatbed.
Methods
FromIdAsync(String) FromIdAsync(String) FromIdAsync(String) FromIdAsync(String)
Creates an instance of a ImageScanner object based on a scanners device information ID. This method is required for broker device enumeration.
public : static IAsyncOperation<ImageScanner> FromIdAsync(PlatForm::String deviceId)public static IAsyncOperation<ImageScanner> FromIdAsync(String deviceId)Public Static Function FromIdAsync(deviceId As String) As IAsyncOperation( Of ImageScanner )// You can use this method in JavaScript.
- deviceId
- PlatForm::String String String String
The device information ID. See DeviceInformation.Id property.
GetDeviceSelector() GetDeviceSelector() GetDeviceSelector() GetDeviceSelector()
Returns the class selection string that apps can use to enumerate scanner devices. This method is required for the brokered device enumeration.
public : static PlatForm::String GetDeviceSelector()public static string GetDeviceSelector()Public Static Function GetDeviceSelector() As string// You can use this method in JavaScript.
The class selection.
IsPreviewSupported(ImageScannerScanSource) IsPreviewSupported(ImageScannerScanSource) IsPreviewSupported(ImageScannerScanSource) IsPreviewSupported(ImageScannerScanSource)
Determines if the specified scan source supports scan preview.
public : PlatForm::Boolean IsPreviewSupported(ImageScannerScanSource scanSource)public bool IsPreviewSupported(ImageScannerScanSource scanSource)Public Function IsPreviewSupported(scanSource As ImageScannerScanSource) As bool// You can use this method in JavaScript.
- scanSource
- ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource
The scan source.
Returns True if the specified scan source supports preview; otherwise False.
IsScanSourceSupported(ImageScannerScanSource) IsScanSourceSupported(ImageScannerScanSource) IsScanSourceSupported(ImageScannerScanSource) IsScanSourceSupported(ImageScannerScanSource)
Determines if the specified scan source is available on the scanner.
public : PlatForm::Boolean IsScanSourceSupported(ImageScannerScanSource value)public bool IsScanSourceSupported(ImageScannerScanSource value)Public Function IsScanSourceSupported(value As ImageScannerScanSource) As bool// You can use this method in JavaScript.
The scan source.
True if the scan source, Flatbed or Feeder, is available; otherwise False.
ScanFilesToFolderAsync(ImageScannerScanSource, StorageFolder) ScanFilesToFolderAsync(ImageScannerScanSource, StorageFolder) ScanFilesToFolderAsync(ImageScannerScanSource, StorageFolder) ScanFilesToFolderAsync(ImageScannerScanSource, StorageFolder)
Starts a scan job with the specified scan source and writes one or multiple images to one multi-page file like TIFF, XPS, and PDF; or one or multiple single-page files like DIB, PNG, JPG, and TIFF to the specified folder location. Returns the progress of the scan.
public : IAsyncOperationWithProgress<ImageScannerScanResult, unsigned int> ScanFilesToFolderAsync(ImageScannerScanSource scanSource, StorageFolder storageFolder)public IAsyncOperationWithProgress<ImageScannerScanResult, uint> ScanFilesToFolderAsync(ImageScannerScanSource scanSource, StorageFolder storageFolder)Public Function ScanFilesToFolderAsync(scanSource As ImageScannerScanSource, storageFolder As StorageFolder) As IAsyncOperationWithProgress( Of ImageScannerScanResult, uint )// You can use this method in JavaScript.
- scanSource
- ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource
The image scan source.
- storageFolder
- StorageFolder StorageFolder StorageFolder StorageFolder
The target folder location of the scanned file.
The list of scanned image files from ImageScannerScanResult and the progress of the WIA scan job from UInt32, which indicates how many files were transferred to the target folder.
Remarks
The files are named using temporary names, with a standard file extension that depends on the file format type.
Note
In Windows Store app, when this method is invoked, the app must be visible and running in the foreground.
When the app cancels the async call, it initiates a cancellation request of the current scan job. There is no guarantee that if the app cancels the async call that the scan job will be canceled. If the cancellation goes through, the scanner may stop for these reasons:
- It takes a few seconds before the scanner stops scanning.
- It stops only when it runs out of paper (for a Feeder acquisition).
- It completes running the scan head to the end of the bed and then fully returns the scan head to its parked location (for a Flatbed acquisition).
Internally the async cancelation will flag the current WIA 2.0 scan job as canceled from within the app. If the WIA device makes the next callback to the WIA service the job cancellation may or may not be successfully communicated to the WIA driver. But, even if the WIA driver receives the cancel request from one of its callbacks there is no guarantee that the driver can successfully stop the scanner from scanning, immediately or after any predictable period of time.
Here's the list of WIA specific HRESULT error codes as well as standard COM HRESULT error codes this function returns.
Note
(the API will call WinRTOriginateError and/or OriginateErrorWithResourceString (all specific WIA errors will have localizable error descriptions) for the WIA specific failure HRESULTs):
| WIA_ERROR_GENERAL_ERROR | WIA_ERROR_PAPER_JAM | WIA_ERROR_PAPER_EMPTY |
| WIA_ERROR_PAPER_PROBLEM | WIA_ERROR_OFFLINE | WIA_ERROR_BUSY |
| WIA_ERROR_WARMING_UP | WIA_ERROR_USER_INTERVENTION | WIA_ERROR_ITEM_DELETED |
| WIA_ERROR_DEVICE_COMMUNICATION | WIA_ERROR_INVALID_COMMAND | WIA_ERROR_INCORRECT_HARDWARE_SETTING |
| WIA_ERROR_DEVICE_LOCKED | WIA_ERROR_EXCEPTION_IN_DRIVER | WIA_ERROR_INVALID_DRIVER_RESPONSE |
| WIA_ERROR_COVER_OPEN | WIA_ERROR_LAMP_OFF | WIA_ERROR_MULTI_FEED |
There are two special cases:
- The WIA’s HRESULT of S_FALSE will be translated to a canceled async call (AsyncStatus.Canceled).
- The WIA’s WIA_ERROR_PAPER_EMPTY will be translated by this API to a successful return (AsyncStatus.Completed) with an empty list of files (IVectorView.Size set to 0). To prevent orphan files, this method deletes any remaining orphan files used to transfer images upon failure, before the failure occurred. The method will save the transfer files as temporary files and keep them until the scan job completes. The app must instruct the user to rescan the document.
ScanPreviewToStreamAsync(ImageScannerScanSource, IRandomAccessStream) ScanPreviewToStreamAsync(ImageScannerScanSource, IRandomAccessStream) ScanPreviewToStreamAsync(ImageScannerScanSource, IRandomAccessStream) ScanPreviewToStreamAsync(ImageScannerScanSource, IRandomAccessStream)
Scans one image from the specified scan source and applies the lowest scan resolution with the selected image file format.
public : IAsyncOperation<ImageScannerPreviewResult> ScanPreviewToStreamAsync(ImageScannerScanSource scanSource, IRandomAccessStream targetStream)public IAsyncOperation<ImageScannerPreviewResult> ScanPreviewToStreamAsync(ImageScannerScanSource scanSource, IRandomAccessStream targetStream)Public Function ScanPreviewToStreamAsync(scanSource As ImageScannerScanSource, targetStream As IRandomAccessStream) As IAsyncOperation( Of ImageScannerPreviewResult )// You can use this method in JavaScript.
- scanSource
- ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource ImageScannerScanSource
The image scan source.
The scanned image file.
The progress of the scan and the scanned file format.
Remarks
Attempting to preview from a Feeder that supports preview but is empty at the time will result in a successful completion of the async call. The app should check for the returned ImageScannerPreviewResult.Succeeded result before attempting to read data from the stream, especially when scanning from the Feeder.