Automatic Document Feeder

Top  Previous  Next

If your image device is equipped with an automatic document feeder (ADF), DTWAIN allows you to scan all of the pages, or set the maximum number of pages to acquire (this is good for those applications that want to acquire only one page, even though the device may support multiple pages).  There are also functions to determine whether to use the ADF or flatbed portion of the device, and to check if there are documents loaded in the feeder.

 

Additionally, there are functions to turn off the automatic feeder capabilities.  For example, you may still want to acquire pages from the feeder, but the feeding of the pages is under your application's control.

 

Enabling / Disabling the Document Feeder

By default DTWAIN always assumes that you will use the document feeder to acquire images and have the pages fed automatically.  If your device is equipped with both a document feeder and a flatbed (which is how most scanners with an add-on document feeder are configured), you can choose to scan from the flatbed portion of the scanner by calling DTWAIN_EnableFeeder with a value of FALSE for the "enable" parameter.  To re-enable the document feeder, you call DTWAIN_EnableFeeder with TRUE for the "enable" parameter.

 

Enabling / Disabling the Automatic Feed

If you wish to use the feeder, but you want to turn off the automatic feeder mode so that your application can have control over when a page is fed, call DTWAIN_EnableAutoFeed function with a FALSE value.  Note that if your application turns off the automatic feeder, the application is responsible for feeding pages. Before trying to turn off the auto-feed mode, it is best that your application turn off the auto-feed only on Sources that have been tested thoroughly when the auto-feed is off.  It is not recommended to assume that turning off the auto-feed for any Source will work correctly, since many Sources don't work correctly if the auto-feed mode is turned off.

 

The functions DTWAIN_FeedPage, DTWAIN_RewindPage, and DTWAIN_ClearPage are used to feed the next page, return the previous page back to acquire area, and clear the next page in the scanner, respectively.  Note that these functions will only work in the following situations:

 

The Source has a document feeder.

The Source supports the auto-feed option (which all should do if a document feeder is attached).

The Source is fully TWAIN compliant as to controlling the feeder programatically.

The language that you are using can capture DTWAIN Notifications and/or set a callback.  The reason why this is important is that a program can only control the feeder pages while in state 5 and 6 (which is during the scanning session, not before).

 

Testing for Document Feeder Availability

To check if a document feeder is available for a particular Source, the DTWAIN_IsFeederSupported function can be used.  The DTWAIN_IsAutoFeedSupported can also be called to test if the auto-feed mode is supported.

 

Query for loaded documents

Most devices that have a document feeder also allow an application to query if the document feeder is empty or have pages loaded.  The DTWAIN_IsFeederLoaded function is used to determine if the feeder is or is not loaded with documents.   This function is only available if the feeder is enabled.  A good use for DTWAIN_IsFeederLoaded would be to call DTWAIN_IsFeederLoaded in a message loop, and not break out of the loop until DTWAIN_IsFeederLoaded returns TRUE.  Another use is to check if the feeder is loaded, and if not, use the flatbed portion of the scanner instead.

 

Example:

 

// Example shows waiting until paper is placed in feeder before acquiring an image.

// Once paper is placed in the feeder, the scanning will automatically start.

void FeederWaitTest( )

{

  DTWAIN_SysInitialize( );

   DTWAIN_SOURCE Source = DTWAIN_SelectSource();

   if ( Source )

   {

        if ( DTWAIN_IsFeederSupported( Source ) )

        {

            DTWAIN_EnableFeeder( Source, TRUE );

 

             // keep looping while there is no paper in the feeder

             while ( ! DTWAIN_IsFeederLoaded(Source) )  { }   // loop forever

 

             // we only got here because someone placed paper in the feeder.

            DTWAIN_AcquireFile(Source, "test.bmp", DTWAIN_BMP, DTWAIN_USELONGNAME, DTWAIN_PT_RGB, 1, TRUE, TRUE, NULL);      

        }

   }                  

  DTWAIN_SysDestroy( );

}

 

 

Note that some devices do not inform of whether documents are loaded in the feeder, so DTWAIN_IsFeederLoaded may always return TRUE (or similarly always return FALSE), even though there may or may not be documents in the feeder.  DTWAIN offers another function, DTWAIN_IsFeederSensitive to determine whether the feeder will be able to detect whether there is paper in the feeder.