Dynamic Web TWAIN-- how the viewer in the picture is saved to the local

Dynamic Web TWAIN scan or load all images can be saved to local disk in the following format: BMP, JPEG, PNG, TIFF (single page or multiple pages) and PDF (single page or multiple pages).

Call the method

Use Dynamic Web TWAIN, you can select one of the following methods to save the image:

format Required API
Single-page document SaveAsBMP() SaveAsJPEG() SaveAsPDF() SaveAsPNG() SaveAsTIFF()
Multi-page PDF file SaveSelectedImagesAsMultiPagePDF() SaveAllAsPDF()
Multi-page TIFF file SaveAllAsMultiPageTIFF() SaveSelectedImagesAsMultiPageTIFF()

code segment:

/* Use it synchronously */
DWObject.SaveAsJPEG("C:\\WebTWAIN\\Images\\ImageData.jpg", 0);
/* Use it asynchronously */
DWObject.SaveAllAsPDF("C:\\WebTWAIN\\Images\\ImageData.pdf", optionalAsyncSuccessFunc, optionalAsyncFailureFunc);
/* Callback functions for Async APIs */
function optionalAsyncSuccessFunc(){
    console.log('successful');
}
function optionalAsyncFailureFunc(errorCode, errorString){
    alert(errorString);
}

From the above code, you can see that you need to provide the full file path to save the image locally, which is sometimes inconvenient. But do not worry, just load the image, like, Dynamic Web TWAIN can also open a "Save As ..." dialog box in order to find the path you want to save the image. The following is a snippet:

DWObject.IfShowFileDialog = true;
DWObject.SaveAsJPEG("",0);

This will open the following dialog box, which contains the method you use to specify the "Save as type":

Note:
In Windows Vista and later versions, Microsoft enhanced security, which means that you can only have a certain location to save the image written permission. If you try to save to a different location, you receive the following error message. You can then save to another directory or first obtaining permission of the directory.

image024

Released two original articles · won praise 4 · Views 4055

Guess you like

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