Handling Template Files
Template files are used to store capability information for a specific TWAIN source. That way, the next time that particularTWAIN source is used, the corresponding template file can provide information on the capabilities used previously.
LEADTOOLS provides the following functions for working with template files:
- L_TwainOpenTemplateFile 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.
- L_TwainAddCapabilityToFile adds a certain capability to the file when the file is opened with write access.
- L_TwainGetNumOfCapsInFile gets the number of capabilities stored in a template file.
- L_TwainGetCapabilityFromFile gets the capability information by passing its index to the function.
- L_TwainCloseTemplateFile closes the file and saves its contents if the file was opened with write access.
- L_TwainTemplateDlg 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. Before calling this function you can determine which user interface to display by calling the L_TwainEnableShowUserInterfaceOnly function.
- L_TwainSaveTemplateFile enumerates all capabilities from the Twain Driver or enumerates the capabilities specified from an array passed to the function. Based on the flag used, the function will save out each capabilitys current value, default value, or possible values.
- L_TwainLoadTemplateFile loads the TWAIN capability values stored in the specified template file and sets the selected TWAIN source using these values
When a user acquires one or more images using the L_TwainAcquire function, 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 L_TwainOpenTemplateFile. The L_TwainGetNumOfCapsInFile function will provide the number of capabilities stored in the template file. This information allows the user to loop through the stored capabilities using the L_TwainGetCapabilityFromFile function. As each capability is obtained, the user can set the capabilities for the TWAIN source using the L_TwainSetCapability function.