Handling Template Files

Template files are used to store capability information for a specific TWAIN source. That way, the next time that TWAIN source is used, the corresponding template file can provide information on the capabilities used previously.

LEADTOOLS provides the following methods for working with template files:

image\sqrblit.gif ShowTemplateDlg displays the scanning dialog provided by the manufacturer of the TWAIN source without actually acquiring the images. Instead it gets the values of all supported capabilities, which will be saved to the specified template file. You can get the capabilities to be save in an event by setting the EnableSaveCapabilityEvent property, and handling the event OnSaveCapabilityEvent event.

image\sqrblit.gif OpenTemplateFile opens a template file for either reading or writing. When a template file is open for reading, the user can get capability information stored within the file. When a template file is opened for writing, capability information can be saved to that file.

image\sqrblit.gif AddCapabilityToFile adds a certain capability to the file when the file is opened with write access.

image\sqrblit.gif GetNumOfCapsInFile gets the number of capabilities stored in a template file.

image\sqrblit.gif GetCapabilityFromFile gets the capability information by passing its index to the method.

image\sqrblit.gif CloseTemplateFile closes the file and saves its contents if the file was opened with write access.

When a user acquires one or more images using the Acquire method, the capability settings used for the TWAIN source can be saved in a template file. The next time the user wishes to use that TWAIN source he or she can open the template file saved previously, for read access, using OpenTemplateFile. The GetNumOfCapsInFile method will provide the number of capabilities stored in the template file. This information allows the user to loop through the stored capabilities using the GetCapabilityFromFile method. As each capability is obtained, the user can set the capabilities for the TWAIN source using the SetCapability method.