Load local image(s) into Dynamic Web TWAIN


Before you try to load any images, bear in mind that as a lightweight component running in web browsers, Dynamic Web TWAIN is only designed to deal with the most basic images in the following formats: BMP, JPEG, PNG, TIFF and PDF. We only guarantee that images generated by Dynamic Web TWAIN can load successfully. If you are trying to load an image that was not generated by Dynamic Web TWAIN, it may or may not work.


With Dynamic Web TWAIN, you can load local images with the methods LoadImage() or LoadImageEx(). Below is a simple code snippet:

DWObject.LoadImage("C:\\WebTWAIN\\Images\\ImageData.jpg", optionalAsyncSuccessFunc, optionalAsyncFailureFunc);

DWObject.LoadImageEx("C:\\WebTWAIN\\Images\\ImageData.jpg", EnumDWT_ImageType.IT_JPG, optionalAsyncSuccessFunc, optionalAsyncFailureFunc); // ImageType: JPG

//Callback functions for async APIs
function optionalAsyncSuccessFunc() {
function optionalAsyncFailureFunc(errorCode, errorString) {

As you can see, you need to provide the complete file path to load an image. It is somewhat clumsy especially when you need to load more than one image. But no worries, Dynamic Web TWAIN can open a "Select File…" dialog for you to locate the image(s) you want to load and like other properties and methods, it’s effortless to use. Below is a code snippet:

DWObject.IfShowFileDialog = true;
DWObject.LoadImageEx("", EnumDWT_ImageType.IT_ALL); //ALL (BMP, JPG, PNG, PDF, TIFF)

Please note that the second parameter ImageType in the method LoadImageEx() would determine the file filter in the "Select File…" dialog.


Starting from v14.0, you can also drag and drop images onto the Dynamic Web TWAIN viewer to load them.


  1. Loading by drag & drop is only supported in the HTML5 edition.
  2. Due to security concerns, you won't be able to get the actual path of an image loaded by drag & drop.


results matching ""

    No results matching ""

    results matching ""

      No results matching ""