How to Discard blank pages automatically

For Dynamic .NET TWAIN v6.x and lower versions only, for V7.x+ please refer to

There are two main ways that you may discard blank pages in Dynamic .NET TWAIN automatically.

1. If the TWAIN driver of your device supports discarding blank pages, you can use the driver's built-in feature.

1a) You can set the IfShowUI property to true to display the User Interface (UI) of the source and you can check the option there (it normally reads 'discard blank').

1b). If you don't want to show the user interface of the source, you can negotiate the ICAP_AUTODISCARDBLANKPAGES capability in code to discard blank page automatically. Please NOTE that this property or capability only works if the scanner itself supports the feature (on the hardware level).

2. If the scanner itself doesn't support discarding blank pages, you can also use the IsBlankImage(Int16) method to do this as a workaround. To detect and discard blank pages automatically, you can do it in the OnPostTransfer event which fires after each transfer. The following code snippet will discard blank pages automatically based upon a defined standard deviation.

private void dynamicDotNetTwain_OnPostTransfer()
            dynamicDotNetTwain.BlankImageMaxStdDev = 10; 
            int i = dynamicDotNetTwain.HowManyImagesInBuffer - 1;            
            if (dynamicDotNetTwain.IsBlankImage((short)(i)))
                MessageBox.Show("Removed image" + i.ToString());
            GC.Collect();	//make garbage collector work to release memory	
In this sample the value of BlankImageMaxStdDev will define how sensitive the blank page detection is. If you are finding pages are not being detected blank often enough then you can increase the value. If you are having issues with the borders of images affecting the blank page detection you may also use the function:
public bool IsBlankImage( short sImageIndex, int iLeft, int iTop, int iRight, int iBottom, bool bFuzzyMatch )
This will allow you to specify a certain region within the page to detect if it's blank. With this you can detect an area inside the borders of the full page.