Home : Proper use of Save/Load Parameters in TWAIN scanning
Q10271 - HOWTO: Proper use of Save/Load Parameters in TWAIN scanning

This article describes how to use DotTwain’s SaveParameters, LoadParameters, SaveXmlParameters and LoadXmlParameters methods to allow your users to scan with specific settings without having to change them every time in the scanner interface.

If the Device.CustomDataSupported property returns true, you should use the SaveParameters and LoadParameters methods.   If the CustomDataSupported property returns false, you must use the SaveXmlParameters and LoadXmlParameters methods.

Difference Between Methods

The SaveParameters and LoadParameters methods use a special TWAIN operation to tell the driver to save or load its settings.  This means the file data is created by the driver, not DotTwain.

The SaveXmlParameters and LoadXmlParameters methods work by saving/loading all settable properties the driver provides in its CAP_SUPPORTEDCAPS. 

Even through SaveXmlParameters will work with all drivers, it’s always best to use SaveParameters when the driver supports it since that data usually contains more information than DotTwain can access.

Saving Parameters

To save parameters you must show the driver interface so the user can select the settings they want.  If Device.EnabledInterfaceOnly returns true, then the device is able to show its interface without scanning by calling the ShowUserInterface method.  If EnableInterfaceOnly returns false, your only choice is to call Acquire and save the settings in the AcquireFinished event.

Be sure to save the settings before calling the Close method or they may be lost.

Loading Parameters

To load the parameters correctly, you must follow these steps:

  1. Open the device.
  2. Call LoadParameters (if CustomDataSupported) or LoadXmlParameters.
  3. Set the HideInterface property to true.
  4. Optionally set the DisplayProgressIndicator property to false.
  5. Call Acquire.

A demo project for Visual Studio 2008, both C# and VB, it attached to this case to provide a working example on using these methods.

Related Articles
No Related Articles Available.

Article Attachments

Related External Links
No Related Links Available.
Help us improve this article...
What did you think of this article?


Tell us why you rated the content this way. (optional)
Approved Comments...
No user comments available for this article.

Powered By InstantKB.NET v1.3
Copyright © 2002, 2020. InstantASP Ltd. All Rights Reserved