Discarding Blank Pages

Top  Previous  Next

Many times, it is desirable to not acquire a page if it is determined to be blank.  This saves disk space when creating image files from the acquisition, as blank pages are not saved.

 

If your TWAIN driver supports discarding blank pages. ..:
 

There are a few TWAIN devices that automatically have the capability to discard blank pages.  Usually, this feature is provided for by setting a custom capability within the TWAIN Source if the application is acquiring images without the device's user interface shown.  If the user interface is shown, these drivers usually provide an option to turn on the automatic discarding of blank pages.   Since setting a custom capability is dependent on the Source, the DTWAIN_SetCapValues function will set whatever capability your TWAIN driver has provided that turns on the feature of automatically discarding pages.

 

The TWAIN specification is unclear on whether this capability should exist as a regular capability instead of a custom capability.  Prior to version 1.9 of the TWAIN specification, there used to be a capability that could be turned on that would discard blank pages (if the TWAIN driver supported this capability).  However, the latest version of the TWAIN specification has deprecated this capability, but some TWAIN drivers may still support it.  The capability is DTWAIN_CV_ICAPAUTODISCARDBLANKPAGES.  Therefore the following may work if the TWAIN device supports this capability ('C' code).

 

DTWAIN_SOURCE Source;

 

Source = DTWAIN_SelectSource( );

 

if ( Source != 0 && DTWAIN_IsCapSupported( Source, DTWAIN_CV_ICAPAUTODISCARDBLANKPAGES ) )

{

  DTWAIN_ARRAY array = DTWAIN_ArrayCreateFromCap( SOURCE, DTWAIN_CV_ICAPAUTODISCARDBLANKPAGES, 1 );

  DTWAIN_ArraySetAtLong( array, 0, 1 );
 

   /* turn on blank page processing */

  DTWAIN_SetCapValues( Source, DTWAIN_CV_ICAPAUTODISCARDBLANKPAGES, DTWAIN_CAPSET, array );

  DTWAIN_ArrayDestroy( array );

}

 

Also, your TWAIN driver still may have a custom capability that sets the automatic discarding of blank pages.  You will need to consult with the manufacturer of your TWAIN driver to see if the driver has the capability to discard blank pages, as well as the capability value to use when calling DTWAIN_SetCapValues.

 

 

If your TWAIN driver does not support discarding of blank pages

 
If your TWAIN driver does not have the ability to discard blank pages, the DTWAIN_SetBlankPageDetection function gives your application the ability to discard blank pages.  By using this function, when a blank page is detected, the page can automatically be discarded, or DTWAIN can send a notification to your application that the page is blank, and your application can decide whether to discard the page or not.