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.
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.
To load the parameters correctly, you must follow these steps:
- Open the device.
- Call LoadParameters (if CustomDataSupported) or LoadXmlParameters.
- Set the HideInterface property to true.
- Optionally set the DisplayProgressIndicator property to false.
- 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.