Scan to a multi-page PDF 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 PDF 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:
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 PDF file is saved ("Multi.pdf").
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 AddToPDF or InsertPDF commands are used to build a multi-page PDF 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.
Multi-page TIFF files can be created instead of PDF files by modifying the code and replacing PDF functions with the corresponding TIFF functions, i.e., replace AddToPDF with AddToTIF, WritePDF with WriteTIF etc.
Note that the demo has been prepared using the 2010 version of VB. For a copy of the demo compatible with older versions of VB.NET download the following ZIP file: