Save image(s) locally


Dynamic Web TWAIN can save all scanned or loaded images locally in the following formats: BMP, JPEG, PNG, TIFF (single-page or multi-page) and PDF (single-page or multi-page).

Calling the methods

With Dynamic Web TWAIN, you can choose one of the following methods to save an image or images:

Code snippet:

/* 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(){
function optionalAsyncFailureFunc(errorCode, errorString){

From the above code, you can see that you need to provide the complete file path to save an image locally which is sometimes inconvenient. But no worries, just like loading an image, Dynamic Web TWAIN can also open a "Save As…" dialog for you to locate the path that you want to save the image(s) to. Below is a code snippet:

DWObject.IfShowFileDialog = true;

This will bring up this dialog box with the "Save as type" specified by the method you use:


On Windows Vista and above, Microsoft has strengthened security which means you can only save images in certain places where you have write permission. If you try to save to other places, you will get the below error message. You can then save to a different directory or first obtain permission for that directory.