Scan Large Amounts of Documents

When you scan documents in hundreds or even thousands, the disk caching feature will come in handy. The related properties are IfAllowLocalCache and BufferMemoryLimit.

By default, the value of IfAllowLocalCache is true. If it's set to false, all the image data will be stored in DIB format as part of the memory occupied by the browser. However, there is a limit of up to 2,048M of physical memory for all 32-bit browsers. The more images you scan, the more memory the browser will consume. Once the maximum memory (2,048M) is reached (mostly only around 1,300M~1,500M because our SDK isn't the only one running in the browser), the newly scanned images will not be loaded into Dynamic Web TWAIN as there is not enough memory and the browser might appear to be hanging.

To turn on disk caching, you only need to set IfAllowLocalCache to true (the default value if not set). With this mode on, the default value of BufferMemoryLimit is 800M. You can adjust the maximum memory setting according to your needs.

If BufferMemoryLimit < 800M, all images will be stored in compressed mode in physical memory. When the memory limit is reached, the image data will be stored on the local hard disk.

If BufferMemoryLimit >= 800M, the images will be stored in non-compressed mode in physical memory. When the memory limit is reached, the image data will be stored on the local hard disk.

NOTE:

  1. All cached data will be encrypted and can only be accessed by Dynamic Web TWAIN.
    On Windows Vista and later For ActiveX and Plug-in Edition: The cached data is stored at "C:\Users\{User Name}\AppData\LocalLow\Dynamsoft\cache".
    For HTML5 Edition: It is stored at "C:\Windows\SysWOW64 {or system32}\Dynamsoft\DynamicWebTwain\ForChrome\cache"
    On Windows XP For ActiveX and Plug-in Edition: The cached data is stored at "C:\Documents and Settings\ {User Name}\Application Data\Dynamsoft\cache".
    For HTML5 Edition: It is stored at "C:\WINDOWS\SysWOW64 {or system32}\Dynamsoft\DynamicWebTwain\ForChrome\cache"
  2. When the scanning page is closed, the cached data will be destroyed and removed from the hard disk automatically.
  3. Although you can scan and load as many images as you want into Dynamic Web TWAIN control, you might not be able to upload all these images to the web server as there is a memory limit (2048M) for 32-bit browsers. When that limit is reached, your browser will probably freeze and/or crash.

The following example shows how to enable disk caching:

  var DWObject;
  Dynamsoft.WebTwainEnv.RegisterEvent('OnWebTwainReady', function() {
    DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
    DWObject.IfAllowLocalCache = true;
  };
  function AcquireImage(){
    DWObject.SelectSource();
    DWObject.OpenSource();
    DWObject.AcquireImage();
  }