How to Discard blank pages automatically

This KB is for Dynamic .NET TWAIN v7.* + only.
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 codes 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 on a defined standard deviation.

public bool OnPostTransfer(Bitmap bit)
            m_ImageCore.ImageProcesser.BlankImageMaxStdDev = 10;
            int i = m_ImageCore.ImageBuffer.HowManyImagesInBuffer - 1;
            if (m_ImageCore.ImageProcesser.IsBlankImage((short)i))
                MessageBox.Show("Removed image" + i.ToString());
            GC.Collect(); //make garbage collector work to release memory
            return true;

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.

Is this page helpful?

Leave a Reply

Your email address will not be published.