Add document feeder support
Important
This article contains information that applies to obsolete Windows operating systems.
A document feeder is a unit attached to or built into a scanner that automatically feeds paper documents in a position to be scanned. For a scanner with a document feeder, the functionality is exposed and controlled through the addition of the properties contained in the following list. For Windows Me and Windows XP, the following properties are located on the root item:
For Windows Me and Windows XP, the following optional document feeder properties are located on the child item:
If a device has a flatbed, a document feeder, and a duplexer, the driver reports the WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES property as FEED | FLAT | DUP
. Make sure that the valid values for WIA_DPS_DOCUMENT_HANDLING_SELECT are set correctly.
As an example, suppose an application intends to perform a duplex scan of three pages from the document feeder. To accomplish this, the application sets the WIA_DPS_DOCUMENT_HANDLING_SELECT property to (FEEDER | DUPLEX) and sets the WIA_DPS_PAGES property to 3. If the application intends to scan the front of the page first, it should set the WIA_DPS_DOCUMENT_HANDLING_SELECT property to FEEDER | DUPLEX | FRONT_FIRST
. After this is done, the application should navigate to the child item from which it should request a data transfer. The minidriver reports the front of the first page in the feeder as page one, the back of that page as page two, and the front of the second page in the feeder as page three.
It is important to remember that if the device has a document feeder, it must support the document feeder properties.
Acquiring data from a document feeder
There are a few changes that must be made in the implementation of the IWiaMiniDrv::drvAcquireItemData method when the scanner acquires images from a document feeder.
An application reads the WIA_DPS_DOCUMENT_HANDLING_CAPABILITIES property to determine whether the scanner supports scanning using the document feeder.
An application reads the WIA_DPS_DOCUMENT_HANDLING_SELECT property to determine whether the scanner is configured to scan using the document feeder.
An application determines whether there is paper in the document feeder by reading WIA_DPS_DOCUMENT_HANDLING_STATUS. If there is no paper in the feeder, set the WIA_DPS_DOCUMENT_HANDLING_STATUS to the proper status code and return WIA_ERROR_PAPER_EMPTY from IWiaMiniDrv::drvAcquireItemData immediately after an acquisition takes place.
Check the WIA_DPS_PAGES property to determine the scanning behavior. If this property is zero, scan all pages until the feeder is empty. If it is positive, scan only the number of pages indicated by the value contained in the WIA_DPS_PAGES property.
Scan the requested number of pages by controlling a loop, continually scanning, and sending data (one page at a time) to the WIA application by calling the IWiaMiniDrvCallBack::MiniDrvCallback method. The following code example shows how this might work:
for(int x=1; x=Pagecount; x++) { \\ Tell scanner to scan an image. \\ Receive image data from scanner. \\ Send the just-scanned image to the registered application. }
If WIA_IPA_TYMED is set to TYMED_CALLBACK or TYMED_MULTIPAGE_CALLBACK, then an extra message (IT_MSG_NEW_PAGE) must be sent after one page has been scanned and before the next one is to be scanned. This is done by calling the wiasSendEndOfPage WIA service utility function.
The number of pages that a document feeder driver returns depends on the setting of the WIA_DPS_PAGES property.
If WIA_DPS_PAGES is zero
If the scanner is unable to scan the first page, return an error code immediately. This includes paper jams and when the scanner runs out of paper.
If the scanner successfully scans the first page and is able to continue scanning but has run out of paper, return the success code WIA_STATUS_END_OF_MEDIA. This signals the application that the transfer was successful, but the scanner has run out of paper. Some applications respond to WIA_ERROR_PAPER_EMPTY in the same way as they would to WIA_STATUS_END_OF_MEDIA.
If the scanner successfully scans the first page and is able to continue scanning but encounters an error that does not result in data loss, return WIA_STATUS_END_OF_MEDIA. This allows the application to recover and to save any pages scanned before the error occurred. Any subsequent scans should return an error code immediately until the scanner has properly recovered from the failure.
If the scanner successfully scans the first page and is able to continue scanning but encounters an error that does result in data loss, return an error code immediately.
If WIA_DPS_PAGES is positive
All rules for which WIA_DPS_PAGES is zero apply.
If the scanner runs out of paper before the requested number of pages are scanned, return WIA_STATUS_END_OF_MEDIA. This allows the application to close the scanning session, thus preserving the number of pages it already scanned successfully. Some applications respond to WIA_ERROR_PAPER_EMPTY the same way as they would to WIA_STATUS_END_OF_MEDIA.