Load local image(s) into Dynamic Web TWAIN

NOTE

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.

Methods

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() {
    console.log(‘successful’);
}
function optionalAsyncFailureFunc(errorCode, errorString) {
    alert(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. Moreover, 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.

Load-local-images-1

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

Load-local-images-2

results matching ""

    No results matching ""

    results matching ""

      No results matching ""