Handling Page Acquisition Failures

Top  Previous  Next

When requesting to acquire an image, there may be times when the unexpected will happen during acquisition of a page.

 

The application may run out of memory while acquiring an image (this is caused by the fact that the resulting bitmap needs memory to be created)
There is a fault with the acquisition device, most likely a paper jam.

 

To overcome these problems, DTWAIN has functions that address most of these problems.  The functions are as follows:

 

DTWAIN_SetMaxRetryAttempts

DTWAIN_GetMaxRetryAttempts

 

The functions above control how many times DTWAIN will attempt to reacquire a failed image.  By default, the maximum number of retries is 3.  This can be changed by calling DTWAIN_SetMaxRetryAttempts with a positive value.   If a 0 is passed to DTWAIN_SetMaxRetryAttempts, no retry is done.  If all retry attempts fail to reacquire the image, then DTWAIN will halt the entire acquisition process.  In addition to the functions above, the DTWAIN_TN_PAGEFAILED notification is sent on page failure.  The return value for this notification also determines the action that DTWAIN should take on a page failure.  See DTWAIN Notification Processing for more information.

 

For devices that have an automatic document feeder, some faulty feeders cause paper jams.  The DTWAIN functions defined above gives your application control on what to do when a paper jam occurs.

 

Please note that it is important that the Source has been properly implemented to handle page failures and recovery.  It has been the case that some Sources do not behave correctly when retrying a failed page.  The only solution for these Sources is for the application to close and re-open the Source (DTWAIN_CloseSource, DTWAIN_OpenSource), and to call the appropriate DTWAIN_Acquirexxxx function again to retrieve the image(s).