Dynamic Web TWAIN-- local image is loaded into the viewer

Dynamic Web TWAIN can handle the following image formats: BMP, JPEG, PNG, TIFF and PDF.

Call the method:

You can use LoadImage () or LoadImageEx () to load the local picture. The following is a simple code snippet:

DWObject.LoadImage("C:\\WebTWAIN\\Images\\ImageData.jpg", optionalAsyncSuccessFunc, <a name="OLE_LINK669"></a><a name="OLE_LINK668"></a>optionalAsyncFailureFunc);
/* ImageType: JPG */
DWObject.LoadImageEx("C:\\WebTWAIN\\Images\\ImageData.jpg", EnumDWT_ImageType.IT_JPG, optionalAsyncSuccessFunc, optionalAsyncFailureFunc); 
/* Callback functions for async APIs */
function optionalAsyncSuccessFunc(){
    console.log('successful');
}
function optionalAsyncFailureFunc(errorCode, errorString){
    alert(errorString);
}

Note that the last two parameters are optional optionalAsyncSuccessFunc and optionalAsyncFailureFunc callback function.

As you can see, you need to provide the full file path to load images. But to do so you need to load multiple images is very troublesome. But do not worry, Dynamic Web TWAIN can open the "Select File ..." dialog box, so you can find the image to be loaded. And other properties and methods, as it is very easy to use. The following is a snippet:

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

Note that the method LoadImageEx () The second parameter "ImageType" will determine the file filter "Select File ..." dialog box.

Released two original articles · won praise 4 · Views 4056

Guess you like

Origin blog.csdn.net/weixin_42320186/article/details/81162754