|
Scanning to a multi-page TIFF file in VB.NET
A sample application using TwainControlX
This example shows how to acquire a series of images from a TWAIN device and save these images as a single multi-page TIFF file. This can be done either using an Automatic Document Feeder (ADF) or by scanning single pages and building the file one image at a time.
To use this demo, you will need to download two files:
|
Trial version of the ActiveX control TwainControlX. (788kB)
Zip file of VB.NET demo project. (28kB)
|
Install TwainControlX, then extract the VB.NET demo files from TCXMult2VBNET.zip, keeping the same directory structure. Start VB.NET, and open the project in solution file 'TCX_Mult2_VBNET\TCX_Mult2_VBNET.sln'.
Run the project and click one of the three buttons.
The first button starts acquiring images in MultiImage mode. This normally requires a scanner with an ADF, but can also be possible with some webcams. When all images have been acquired, a multi-page TIFF file is saved (C:\Multi.tif).
The second or third buttons start acquiring images one at a time. After each one, a message box asks the user whether to continue or to stop. The AddToTIF or InsertTIF commands are used to build a multi-page TIFF file from the individual images.
After each image is acquired, the code in 'AxTwain1_OnAcquire' will run. This displays the current image in a PictureBox control.
Default settings for the image size and resolution will be used. This usually means that the image is too big to display in the PictureBox control, so only the top left portion of the image will be seen on screen. The whole image will be saved to file.
Multi-page PDF files can be created instead of TIFF files by modifying the code and replacing TIFF functions with the corresponding PDF functions, i.e., replace AddToTIF with AddToPDF, WriteTIF with WritePDF etc.
|
|