Table of contents

Thanks for Downloading Dynamic Web TWAIN 30-Day Trial!

Your download will start shortly. If your download does not begin, click here to retry.

Exporting Locally

Prerequisite: DWT Initialization
Prerequisite: Managing the Image Buffer

DWT offers several methods to save images from the WebTwain image buffer locally. This includes saving the images to files on the end user’s file system, exporting from the image buffer to binary Blobs and Base64 strings, and also printing to connected printers.

Saving Locally

The WebTwain image buffer can output images directly to disk, and supports BMP , JPG , TIF , PNG and PDF formats. Of note, TIF and PDF come with multi-image support. Learn more about supported file formats here.

Each file format has its own file saving API, as shown here:

Note that multi-page saving requires separate APIs from their single page counterparts.

Exporting to Binary

The image buffer can export images as Blobs or Base64 strings, which are useful for processing images outside of DWT, whether for custom image upload logic, or other purposes within the web application.

Exporting to Blob

ConvertToBlob() converts selected images to a Blob, as demonstrated here:

DWTObject.ConvertToBlob(
    [0, 1, 2],
    Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF,
    function(result, indices, type) {
        console.log(result.size);
    },
    function(errorCode, errorString) {
        console.log(errorString);
    }
);

APIs used:

Here, ConvertToBlob() takes a zero-indexed array of image indices (of the image buffer) which indicates the images it exports, and uses the Dynamsoft.DWT.EnumDWT_ImageType enum to specify the file format (in this case, single-page PDF). Just as when saving to files locally, use the dedicated multi-page enums when saving multi-page PDFs and TIFs.

The Blob accessible through the result argument of the success callback.

Exporting to Base64 String

Likewise, ConvertToBase64() outputs a Base64 string:

DWTObject.ConvertToBase64(
    [0, 1, 2],
    Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF,
    function(result, indices, type) {
        console.log(result.getData(0, result.getLength()));
    },
    function(errorCode, errorString) {
        console.log(errorString);
    }
);

APIs used:

The Base 64 string accessible through the result argument of the success callback. Note that this is a Base64Result object.

Print

Finally, DWT can also print directly to a printer through the Print() API. This API brings all images from the image buffer into the browser’s print dialog. Alternatively, while running in Windows Service Mode, the API can also take an argument to use the Windows OS print dialog instead.

Is this page helpful?

YesYes NoNo

In this article: