Using TwainSession.SaveTemplate to Save a Subset of Settings

Saving the settings of your TWAIN device is a very important feature which is fully supported by LEADTOOLS. For the end-user, it allows them to load and save different scanning profiles and options they use on a regular basis such as “high resolution color photo”, “medium quality black and white document”, or “auto-cropped receipt”. One caveat to this feature is that it saves all of the settings, which comes with a few downsides:

  1. Large template files
  2. Longer execution time
  3. Most importantly…That template file will only work on one scanner

To alleviate these problems, LEADTOOLS now has a new overload for its TwainSession.SaveTemplateFile function which allows you to save a subset of settings rather than the entire collection. As long as you are saving core, mandatory settings that are supported by all TWAIN scanners, you can use these templates regardless of the hardware device being used!


int[] nCapabilitiesToSave = { (int)TwainCapabilityType.ImagePixelType, 
                              (int)TwainCapabilityType.ImageXResolution, 
                              (int)TwainCapabilityType.ImageYResolution };

_twSession.SaveTemplateFile(saveDlg.FileName, 
                            nCapabilitiesToSave, 
                            SaveCapabilityOptions.Current);

For a complete example, check out the original forum post.

This entry was posted in Document Imaging, General Imaging and tagged , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *