EZTwain Pro 3.0 - Duplex Scanning

Overview  Download  Licensing  Features  Code Wizard  Stories  User GuidePDF file

Here is pseudo-code to scan a page duplex - i.e. both sides - into a 'front' file and a 'back' file.

TWAIN_SetMultiTransfer(1)                  ' leave source open after Acquire
If TWAIN_OpenDefaultSource() = 1 Then
If TWAIN_GetDuplexSupport() > 0 Then   ' check for duplex support
TWAIN_SelectFeeder(1)              ' turn on the document feeder
TWAIN_EnableDuplex(1)              ' enable duplex scanning
err = TWAIN_AcquireToFilename(0, "front.tif")
If err = 0 Then
	err = TWAIN_AcquireToFilename(0, "back.tif");
End If
End If
End If
TWAIN_UnloadSourceManager()                ' unload TWAIN subsystem
  • The key fact to know about duplex scanning is that TWAIN treats the two sides of a page as if they were two single-sided pages. When you turn on duplex, the scanner just transfers twice as many images.
  • Some scanners that physically have a 'document feeder' don't admit it when queried through TWAIN. On those scanners SelectFeeder will fail, probably harmlessly.
  • Some scanners can feed the next page while your program processes the last one - this can speed up batch scanning: See the TWAIN_SetAutoFeed function.
  • A 'Source' (device) must be open when you call TWAIN_GetDuplexSupport.