Dev Center
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.

{WebTwainObject} IO

The properties and methods on this page live in the namespace {WebTwainObject}. {WebTwainObject} denotes the WebTwain instance. Learn about how to create a web twain object.

Methods

Input Methods

       
LoadImage() LoadImageEx() LoadImageFromBase64Binary() LoadImageFromBinary()
LoadDibFromClipboard() FTPDownload() FTPDownloadEx() HTTPDownload()
HTTPDownloadEx() HTTPDownloadThroughPost()    

Output Methods

     
ConvertToBase64() ConvertToBlob() FTPUpload()
FTPUploadEx() FTPUploadAllAsMultiPageTIFF() FTPUploadAllAsPDF()
FTPUploadAsMultiPagePDF() FTPUploadAsMultiPageTIFF() HTTPUpload()
HTTPUploadThroughPutEx() HTTPUploadThroughPost() HTTPUploadThroughPostEx()
HTTPUploadAllThroughPostAsMultiPageTIFF() HTTPUploadAllThroughPostAsPDF() HTTPUploadThroughPostAsMultiPagePDF()
HTTPUploadThroughPostAsMultiPageTIFF() OutputSelectedAreaAsync() SaveAsBMP()
SaveAsJPEG() SaveAsPDF() SaveAsPNG()
SaveAsTIFF() SaveSelectedImagesAsMultiPagePDF() SaveSelectedImagesAsMultiPageTIFF()
SaveAllAsMultiPageTIFF() SaveAllAsPDF()  

Other Methods

       
ClearTiffCustomTag() SetTiffCustomTag() ClearAllHTTPFormField() SetHTTPFormField()
SetHTTPHeader() SetUploadSegment() ShowFileDialog() Print()
PrintEx()      

Properties

       
FTPPassword FTPPort FTPUserName IfPASVMode
HttpFieldNameOfUploadedImage HTTPPort IfSSL HTTPPostResponseString
IfShowFileDialog IfShowCancelDialogWhenImageTransfer IfShowProgressBar JPEGQuality
IfTiffMultiPage TIFFCompressionType MaxUploadImageSize  

Events

     
OnGetFilePath OnPostLoad OnInternetTransferPercentage

The Android Service Edition only supports a subset of the APIs available in the Desktop Service Edition. For the APIs that are compatible with both editions, the usage remains the same. To learn how to use the APIs, please refer to the documentation for the Desktop Service Edition.

Methods

Input Methods

       
LoadImageEx() LoadImageFromBase64Binary() LoadImageFromBinary() LoadDibFromClipboard()
HTTPDownload() HTTPDownloadEx() HTTPDownloadThroughPost()  

Output Methods

     
ConvertToBase64() ConvertToBlob() HTTPUpload()
HTTPUploadThroughPutEx() HTTPUploadThroughPost() HTTPUploadThroughPostEx()
HTTPUploadAllThroughPostAsMultiPageTIFF() HTTPUploadAllThroughPostAsPDF() HTTPUploadThroughPostAsMultiPagePDF()
HTTPUploadThroughPostAsMultiPageTIFF() SaveAsBMP() SaveAsJPEG()
SaveAsPDF() SaveAsPNG() SaveAsTIFF()
SaveSelectedImagesAsMultiPagePDF() SaveSelectedImagesAsMultiPageTIFF() SaveAllAsMultiPageTIFF()
SaveAllAsPDF() ShareImages()  

Other Methods

       
ClearTiffCustomTag() SetTiffCustomTag() ClearAllHTTPFormField() SetHTTPFormField()
SetHTTPHeader() SetUploadSegment() Print() PrintEx()

Properties

       
HttpFieldNameOfUploadedImage HTTPPort IfSSL HTTPPostResponseString
IfShowCancelDialogWhenImageTransfer IfShowProgressBar JPEGQuality IfTiffMultiPage
TIFFCompressionType MaxUploadImageSize    

Events

   
OnPostLoad OnInternetTransferPercentage

LoadImage()

Load image(s) specified by its absolute path.

Syntax

LoadImage(
    fileName: string
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
LoadImage(
    fileName: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The path of the image to load.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v10.0+ v11.0+ v12.1+ not supported

Example

DWObject.LoadImage(
    "C:\\test\\DWT.jpg",
    function () {
        console.log("success");
    },
    function (errorCode, errorString) {
        console.log(errorString);
    }
);

LoadImageEx()

Load image(s) specified by its absolute path.

Syntax

LoadImageEx(
    fileName: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
LoadImageEx(
    fileName: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The path of the image to load.

type: The format of the image. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage Notes

You can set IfShowFileDialog before calling this API to enable/disable “Open File” dialog.

Example

DWObject.IfShowFileDialog = true; //"Open File" dialog will be opened.

DWObject.LoadImageEx(
    "", //file name can be empty if "Open File" dialog is called.
    Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG,
    function () {
        console.log("success");
    },
    function (errorCode, errorString) {
        console.log(errorString);
    }
);
DWObject.IfShowFileDialog = false; //Default value is true.

DWObject.LoadImageEx(
    "C:\\test\\DWT.jpg",
    Dynamsoft.DWT.EnumDWT_ImageType.IT_JPG,
    function () {
        console.log("success");
    },
    function (errorCode, errorString) {
        console.log(errorString);
    }
);

Remark

Load Guide


LoadImageFromBase64Binary()

Load image(s) from a base64 string.

Syntax

LoadImageFromBase64Binary(
    imageData: string,
    imageType: Dynamsoft.DWT.EnumDWT_ImageType
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
LoadImageFromBase64Binary(
    imageData: string,
    imageType: Dynamsoft.DWT.EnumDWT_ImageType,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

imageData: The image data which is a base64 string without the data URI scheme.

imageType: The format of the image. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.2+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage Notes

You may leverage ConvertToBase64() to get a base64 string.

Example

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

Remark

Load Guide


LoadImageFromBinary()

Load image(s) from a binary object (Blob or ArrayBuffer).

Syntax

LoadImageFromBinary(
    imageData: Blob | ArrayBuffer,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

imageData: The image data.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v16.0+ v16.0+ v16.0+ v16.0+ v18.2+

Usage Notes

You may leverage ConvertToBlob() to get a Blob object.

Example

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

Remark

Load Guide


LoadDibFromClipboard()

Load an image from the system clipboard. The image must be in DIB format.

Syntax

LoadDibFromClipboard(): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
LoadDibFromClipboard(
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.1+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage Notes

If called without any callback functions, these methods (except for LoadImageFromBinary() ) become synchronously and return a boolean value to indicate whether it succeeded.

However, calling them asynchronously is recommended.


OnGetFilePath

This event is triggered when ShowFileDialog() is called or when LoadImageEx() is called with IfShowFileDialog set to true.

Syntax

RegisterEvent(
    "OnGetFilePath",
    function (
        isSave: number,
        filesCount: number,
        index: number,
        directory: string,
        fileName: string
    ) {}
);

Parameters

isSave: Whether or not the event is triggered after a save-file dialog was shown. 0 means false, 1 means true.

filesCount: How many files were selected.

index: The index of the current image.

directory: The parent directory of currently selected file(s), “\\” is not included. If the methed ShowFileDialog() failed, the initial directory path set in the ShowFileDialog() method is returned.

fileName: The current file name.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v10.0+ v10.0+ v11.0+ v12.1+

Example

DWObject.RegisterEvent('OnGetFilePath', function(isSave, filesCount, index, directory, filename) {
    alert("isSave:" + isSave + " fileCount: " +  filesCount + " index: " +  index + " directory: " +  directory + "\\" +  filename);
});

OnPostLoad

This event is triggered when a file from a local directory has been loaded into the control.

Syntax

RegisterEvent(
    "OnPostLoad",
    function (directory: string, fileName: string, fileType: string) {}
);

Parameters

directory: The directory of the loaded file. For example, “C:\Users\[username]\Downloads”.

fileName: The name of the loaded file. For example, “image1.jpg”.

fileType: The file type. Please refer to EnumDWT_ImageType.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.3+ v10.0+ v10.0+ v11.0+ v12.1+

Example

DWObject.RegisterEvent("OnPostLoad", function (path, name, type) {
    alert(path + "\\" + name);
});

FTPDownload()

Download the specified file via FTP.

Syntax

FTPDownload(
    host: string,
    path: string,
    successCallback: () => void,
    failureCallBack: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the file to download.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+

FTPDownloadEx()

Download the specified file via FTP.

Syntax

FTPDownloadEx(
    host: string,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallBack: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the file to download.

type: The format of the file. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+

Example

/* The sample file path is: 
 * "ftp://192.168.8.20/files/sample.pdf"
 */
var onSuccess = function() {
    console.log("Downloaded a file successfully!");
};

var onFailure = function(errorCode, errorString) {
    console.log(errorString);
};

DWObject.FTPPort = 21;
DWObject.FTPUserName = "FTPUser";
DWObject.FTPPassword = "SomePassword";
DWObject.FTPDownloadEx("192.168.8.20", "/files/sample.pdf", Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, onSuccess, onFailure);

FTPUpload()

Upload the specified image via FTP.

Syntax

FTPUpload(
    host: string,
    index: number,
    path: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

index: Specify the index of the image in the buffer. The index is 0-based.

path: The path to save the file.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+

Example

var onSuccess = function() {
    console.log("Uploaded a file successfully!");
};

var onFailure = function(errorCode, errorString) {
    console.log(errorString);
};

DWObject.FTPUserName = 'test';
DWObject.FTPPort = 21;
DWObject.FTPPassword = 'test';
DWObject.FTPUpload(
    '192.168.8.222', //The FTP Host
    0, // The index of the image
    'test.pdf', // The path & name of the file 
    OnSuccess, // Callback in case of success
    OnFailure // Callback in case of failure
);

FTPUploadEx()

Upload the specified image via FTP.

Syntax

FTPUploadEx(
    host: string,
    index: number,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

index: Specify the index of the image in the buffer. The index is 0-based.

path: The path to save the file.

type: The format of the file. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+

FTPUploadAllAsMultiPageTIFF()

Upload all images as a multi-page TIFF via FTP.

Syntax

FTPUploadAllAsMultiPageTIFF(
    host: string,
    path: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the path to save the file.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+

FTPUploadAllAsPDF()

Upload all images as a multi-page PDF via FTP.

Syntax

FTPUploadAllAsPDF(
    host: string,
    path: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the path to save the file.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+

FTPUploadAsMultiPagePDF()

Upload selected images as a multi-page PDF via FTP.

Syntax

FTPUploadAsMultiPagePDF(
    host: string,
    path: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the path to save the file.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+

FTPUploadAsMultiPageTIFF()

Upload selected images as a multi-page TIFF via FTP.

Syntax

FTPUploadAsMultiPageTIFF(
    host: string,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The FTP Host.

path: Specify the path to save the file.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+

FTPUserName

The user name to connect to the FTP.

Syntax

FTPUserName: string;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+

FTPPassword

The password to connect to the FTP.

Syntax

FTPPassword: string;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+

FTPPort

The port to connect to the FTP.

Syntax

FTPPort: number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+

IfPASVMode

Return or set whether to use passive mode when connect to the FTP.

Syntax

IfPASVMode: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+

HTTPPassword

Return or set the password used to log into the HTTP server.

Syntax

HTTPPassword: string;

HTTPUserName

Return or set the user name used to log into the HTTP server.

Syntax

HTTPUserName: string;

HTTPDownload()

Download the specified file via a HTTP Get request.

Syntax

HTTPDownload(
    host: string,
    path: string,
    successCallback: () => void,
    failureCallback: (
        errorCode: number,
        errorString: string) => void
): void;

Parameters

host: The HTTP Host.

path: Specify the path of the file to download.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v18.2+

Example

/* The sample file path is: 
 * "http://localhost:300/files/sample.tif"
 */
var onSuccess = function() {
    console.log("Downloaded a file successfully!");
};

var onFailure = function(errorCode, errorString) {
    console.log(errorString);
};

DWObject.HTTPPort = 300;
DWObject.HTTPDownload("localhost", "/files/sample.tif", onSuccess, onFailure);

Remark

Download Guide


HTTPDownloadEx()

Download the specified file via a HTTP Get request.

Syntax

HTTPDownloadEx(
    host: string,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The HTTP Host.

path: Specify the path of the file to download.

type: The format of the file. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.

Example

In this example, the URL points to a server-side script.

The server-side script can be written in any language and in any logic as long as it returns a file. Please refer to Download-Server-Script.

/* The sample file path is: 
 * "http://localhost:300/files/sample.tif"
 */
var onSuccess = function() {
    console.log("Downloaded a file successfully!");
};

var onFailure = function(errorCode, errorString) {
    console.log(errorString);
};

DWObject.HTTPPort = 300;
DWObject.HTTPDownloadEx("localhost", "/getFile.aspx", Dynamsoft.DWT.EnumDWT_ImageType.IT_TIF, onSuccess, onFailure);

Remark

Download Guide


HTTPDownloadThroughPost()

Download the specified file via a HTTP Post request.

Syntax

HTTPDownloadThroughPost(
    host: string,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string, response?: any) => void,
): void;

Parameters

host: The HTTP Host.

path: Specify the path of the file to download.

type: The format of the file. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response from your server.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported v5.0+ v5.0+ v5.0+ v5.0+ v18.2+

HTTPUpload()

Upload the specified image(s) via a HTTP Post.

Syntax

HTTPUpload(
    URL: string,
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    dataFormat: Dynamsoft.DWT.EnumDWT_UploadDataFormat | number,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void
): void;
HTTPUpload(
    URL: string,
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    dataFormat: Dynamsoft.DWT.EnumDWT_UploadDataFormat | number,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void
): void;

Parameters

URL: The server-side script to receive the post. For the sample code of Server Script, please refer to Upload-Server-Script.

indices: Specify the image(s).

type: The format of the file. Please refer to EnumDWT_ImageType.

dataFormat: Whether to upload the file as binary or a base64 string. Please refer to EnumDWT_UploadDataFormat.

fileName: The file name. If fileName specifies the extension of the file additionally,

  • if the extension is not the same as the format of the file which is specified by type, the extra extension will be added to the file name. For example, fileName is set to "test.jpg", and type is Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, the final file name would be test.jpg.pdf and the file format is PDF.
  • if the extension is the same as the format of the file which is specified by type, the file name equals to the string which is specified by fileName. For example, fileName is set to "test.pdf", and type is Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, the final file name would be test.pdf and the file format is PDF.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode The error code.
  • errorString The error string.
  • response The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v18.0+ v12.0+ v12.0+ v12.0+ v12.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.

Example

DWObject.HTTPUpload(
    'https://www.dynamsoft.com/SaveToFile.aspx', 
    [0,1],  
    Dynamsoft.DWT.EnumDWT_ImageType.IT_PDF, 
    Dynamsoft.DWT.EnumDWT_UploadDataFormat.Binary, 
    'test.pdf', 
    OnEmptyResponse, 
    OnServerReturnedSomething
);

function OnEmptyResponse() {
    console.log('Success');
}

function OnServerReturnedSomething(errCode, errString, responseStr) {
    console.log(errString);
}

Remark

Upload Guide


HTTPUploadThroughPutEx()

Upload the specified image via a HTTP Put request.

Syntax

HTTPUploadThroughPutEx(
    host: string,
    index: number,
    path: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

host: The HTTP Host.

index: Specify the image.

path: Specify the path to put the file.

type: The format of the file. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+ v18.2+

HTTPUploadThroughPost()

Upload the specified image via a HTTP Post request.

Syntax

HTTPUploadThroughPost(
    host: string,
    index: number,
    target: string,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (errorCode: number, errorString: string, response: string) => void
): void;

Parameters

host: The HTTP Host.

index: Specify the image.

target: The target where the request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.

Example

var strHTTPServer = location.hostname; //The name of the HTTP server. For example: "www.dynamsoft.com";
var CurrentPathName = unescape(location.pathname);
var CurrentPath = CurrentPathName.substring(0, CurrentPathName.lastIndexOf("/") + 1);
var strActionPage = CurrentPath + "SaveToFile.aspx";

DWObject.IfSSL = false; // Set whether SSL is used
DWObject.HTTPPort = location.port == "" ? 100 : location.port;

var Digital = new Date();
var uploadfilename = Digital.getMilliseconds();

DWObject.HTTPUploadThroughPost(
    strHTTPServer,
    DWObject.CurrentImageIndexInBuffer,
    strActionPage,
    uploadfilename + ".jpg",
    function () {
        console.log("Empty response");
    },
    function (errorCode,errorString,response) {
        console.log(response);
    }
);

HTTPUploadThroughPostEx()

Upload the specified image in a specific image format via a HTTP Post request.

Syntax

HTTPUploadThroughPostEx(
    host: string,
    index: number,
    target: string,
    fileName: string,
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (
        errorCode: number,
        errorString: string,
        response: string) => void
): void;

Parameters

host: The HTTP Host.

index: Specify the image.

target: The target where the request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

type: The format of the file. Please refer to EnumDWT_ImageType.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.


HTTPUploadAllThroughPostAsMultiPageTIFF()

Upload all images in the buffer as a TIFF file via a HTTP Post request.

Syntax

HTTPUploadAllThroughPostAsMultiPageTIFF(
    host: string,
    target: string,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (
        errorCode: number,
        errorString: string,
        response: string) => void
): void;

Parameters

host: The HTTP Host.

target: The target wherethe request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v4.0+ v4.0+ v4.0+ v4.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.


HTTPUploadAllThroughPostAsPDF()

Upload all images in the buffer as a PDF file via a HTTP Post request.

Syntax

HTTPUploadAllThroughPostAsPDF(
    host: string,
    target: string,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (
        errorCode: number,
        errorString: string,
        response: string) => void
): void;

Parameters

host: The HTTP Host.

target: The target where the request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.


HTTPUploadThroughPostAsMultiPagePDF()

Upload all selected images in the buffer as a PDF file via a HTTP Post request.

Syntax

HTTPUploadThroughPostAsMultiPagePDF(
    host: string,
    target: string,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (
        errorCode: number,
        errorString: string,
        response: string) => void
): void;

Parameters

host: The HTTP Host.

target: The target where the request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.


HTTPUploadThroughPostAsMultiPageTIFF()

Upload all selected images in the buffer as a TIFF file via a HTTP Post request.

Syntax

HTTPUploadThroughPostAsMultiPageTIFF(
    host: string,
    target: string,
    fileName: string,
    onEmptyResponse: () => void,
    onServerReturnedSomething: (
        errorCode: number,
        errorString: string,
        response: string) => void
): void;

Parameters

host: The HTTP Host.

target: The target where the request is sent. For the sample code of Server Script, please refer to Upload-Server-Script.

fileName: The file name.

onEmptyResponse: A callback function that is executed if the response is empty.

onServerReturnedSomething: A callback function that is executed if the response is not empty.

  • errorCode: The error code.
  • errorString: The error string.
  • response: The response string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+ v18.2+

Usage Notes

If you want to use this method to upload / download files through HTTPS, please don’t forget to set IfSSL to true and set the correct HTTPPort.


HttpFieldNameOfUploadedImage

Return or set the field name for the uploaded file. By default, it’s “RemoteFile”.

Syntax

HttpFieldNameOfUploadedImage: string;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v6.0+ v6.0+ v6.0+ v6.0+

HTTPPort

Return or set the HTTP Port. The default value is 80.

Syntax

HTTPPort: number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.2.1+ v4.2.1+ v4.2.1+ v4.2.1+ v4.2.1+

IfSSL

Return or set whether to use SSL in HTTP requests. The default value is false.

Syntax

IfSSL: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+

HTTPPostResponseString

Return the response string of the latest HTTP Post request.

Syntax

readonly HTTPPostResponseString: string;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v3.0.3+ v3.0.3+ v3.0.3+ v3.0.3+ v3.0.3+

MaxUploadImageSize

Return or set the maximum allowed size of a file to upload (in bytes). The default value is -1 which indicates there is no limit over the upload size. The value should be equal or smaller than 2147483647 which essentially means 2 GB.

Syntax

MaxUploadImageSize: number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+

OnInternetTransferPercentage

This event is triggered multiple times during a HTTP upload or download request.

Syntax

RegisterEvent("OnInternetTransferPercentage", function (percentage: number) {});

Parameters

percentage: Return the progress by percentage.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+

ConvertToBase64()

Convert the specified images to a base64 string.

Syntax

ConvertToBase64(
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: (result: Base64Result, indices: number[], type: number) => void,
    failureCallBack: (errorCode: number, errorString: string) => void
): void;

Parameters

indices: Specify one or multiple images.

type: The file type. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

  • result: The resulting base64 string. Please refer to Base64Result.
  • indices: The indices of the converted images.
  • type: The file type.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v18.0+ v12.0+ v12.0+ v12.0+ v12.1+

Usage Notes

getData() returns the pure base64 string without the data URI scheme. For example, “/9j/4AAQSkZJRgABA…”. If you want to use the string, you probably need to add the scheme. For example, “data:image/png; base64, /9j/4AAQSkZJRgABA…”.

Example

DWObject.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);
    }
);

ConvertToBlob()

Convert the specified images to a blob.

Syntax

ConvertToBlob(
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    successCallback: (result: Blob, indices: number[], type: number) => void,
    failureCallBack: (errorCode: number, errorString: string) => void
): void;

Parameters

indices: Specify one or multiple images.

type: The file type. Please refer to EnumDWT_ImageType.

successCallback: A callback function that is executed if the request succeeds.

  • result: The resulting blob.
  • indices: The indices of the converted images.
  • type: The file type.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
not supported v13.0+ v13.0+ v13.0+ v13.0+

Example

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

OutputSelectedAreaAsync()

Copy selected area to Blob or base64.

Syntax

OutputSelectedAreaAsync(
    index: number,
    area: {
        x: number,
        y: number,
        width: number,
        height: number
    },
    type: Dynamsoft.DWT.EnumDWT_ImageType | number,
    imageFormatType: Dynamsoft.DWT.EnumDWT_ImageFormatType | number
): Promise < Blob | string > ;

Parameters

index: Image to be copied from.

area: Area of image to be copied. X,Y is top left corner origin, width and height is size of area to be copied

type: The target image type of the blob/base64 (See Dynamsoft.DWT.EnumDWT_ImageType for allowable types).

imageFormatType: Specify if the return should be Blob or base64 string (Dynamsoft.DWT.EnumDWT_ImageFormatType for values)

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
N/A v18.4+ v18.4+ v18.4+ v18.4+ v18.4+

SaveAsBMP()

Save the specified image as a BMP file.

Syntax

SaveAsBMP(
    fileName: string,
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAsBMP(
    fileName: string,
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

index: The index which specifies the image to save.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+ v18.2+

Usage Notes

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAsJPEG()

Save the specified image as a JPEG file.

Syntax

SaveAsJPEG(
    fileName: string,
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAsJPEG(
    fileName: string,
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

index: The index which specifies the image to save.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAsPDF()

Save the specified image as a PDF file.

Syntax

SaveAsPDF(
    fileName: string,
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAsPDF(
    fileName: string,
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

index: The index which specifies the image to save.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

Learn about how to config PDF save settings.

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAsPNG()

Save the specified image as a PNG file.

Syntax

SaveAsPNG(
    fileName: string,
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAsPNG(
    fileName: string,
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

index: The index which specifies the image to save.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAsTIFF()

Save the specified image as a TIFF file.

Syntax

SaveAsTIFF(
    fileName: string,
    index: number
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAsTIFF(
    fileName: string,
    index: number,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v3.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Parameters

fileName: The name to save to (or specify the absolute path).

index: The index which specifies the image to save.

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Usage notes

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAllAsMultiPageTIFF()

Saves all the images in buffer as a multi-page TIFF file.

Syntax

SaveAllAsMultiPageTIFF(
    fileName: string
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAllAsMultiPageTIFF(
    fileName: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode The error code.
  • errorString The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v4.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveAllAsPDF()

Saves all the images in buffer as a multi-page PDF file.

Syntax

SaveAllAsPDF(
    fileName: string
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveAllAsPDF(
    fileName: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

Learn about how to config PDF save settings.

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveSelectedImagesAsMultiPagePDF()

Saves all selected images in buffer as a multi-page PDF file.

Syntax

SaveSelectedImagesAsMultiPagePDF(
    fileName: string
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveSelectedImagesAsMultiPagePDF(
    fileName: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

Learn about how to config PDF save settings.

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


SaveSelectedImagesAsMultiPageTIFF()

Saves all selected images in buffer as a multi-page TIFF file.

Syntax

SaveSelectedImagesAsMultiPageTIFF(
    fileName: string
): boolean;

// Call this API asynchronously to avoid blocking the browser's main thread 
SaveSelectedImagesAsMultiPageTIFF(
    fileName: string,
    successCallback: () => void,
    failureCallback: (errorCode: number, errorString: string) => void
): void;

Parameters

fileName: The name to save to (or specify the absolute path).

successCallback: A callback function that is executed if the request succeeds.

failureCallback: A callback function that is executed if the request fails.

  • errorCode: The error code.
  • errorString: The error string.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

Usage notes

If called without any callback functions, these methods become synchronously and return a boolean value to indicate whether it succeeded. However, calling them asynchronously is recommended.

If you would like to save images by showing the ‘Save File’ dialog box, you can set IfShowFileDialog to true.


ShareImages()

Shares images using Android’s built in share functionality.

Syntax

ShareImages(
    fileName: string,
    indices: number[],
    type: Dynamsoft.DWT.EnumDWT_ImageType
): Promise< void>; 

If indicies is an array, the behavour is dependant on type:

  • If type is set to PDF or TIFF, a single multi-page file is shared

  • If any other type is set, mutiple single page files will be shared in the format of filename1.filetype, filename2.filetype, etc.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
not supported not supported not supported not supported not supported v18.2+

ClearTiffCustomTag()

Clear the content of all custom tiff tags.

Syntax

ClearTiffCustomTag(): boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v10.0+ v11.0+ v12.1+

SetTiffCustomTag()

Sets a custom tiff tag (up to 32 tags). The string to be set in a tag can be base64 encoded.

Syntax

SetTiffCustomTag(
    id: number,
    content: string,
    useBase64Encoding: boolean
): boolean;

Parameters

id: The id of the custom tag.

content: The content of the tag.

useBase64Encoding: Whether the content is encoded.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v10.0+ v10.0+ v10.0+ v11.0+ v12.1+

Usage notes

The method SetTiffCustomTag() sets one or up to 32 tags to be added to a TIFF file when generating it. The content of the tags can be plain text or a base64-encoded string. If it’s encoded, it’ll be decoded when generating the TIFF file.

To make sure you don’t included unwanted tags, call ClearTiffCustomTag() to clear old tags before setting up new ones.

Example

DWObject.ClearTiffCustomTag();
DWObject.SetTiffCustomTag(700, "Created By DWT", false);
DWObject.SaveAsTIFF("C:\\DWT.tiff", 0);

ClearAllHTTPFormField()

Clear all the custom fields from the HTTP Post Form.

Syntax

ClearAllHTTPFormField(): boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+

SetHTTPFormField()

Add a custom field to the HTTP Post Form. Or add a binary file to the HTTP Post Form.

Syntax

SetHTTPFormField(
    name: string,
    value: string
): boolean;
SetHTTPFormField(
    name: string,
    content: Blob,
    fileName?: string
): boolean;

Parameters

name: The name of the field.

value: The value of the field.

content: The content of the file.

fileName: The name of the file.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v5.0+ v5.0+ v5.0+ v5.0+

SetHTTPHeader()

Add a custom header to the HTTP Post Form.

Syntax

SetHTTPHeader(
    name: string,
    value: string
): boolean;

Parameters

name: The name of the header.

value: The value of the header.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
not supported v12.0+ v12.0+ v12.0+ v12.0+

SetUploadSegment()

Set the segmentation threshold and segment size.

Syntax

SetUploadSegment(
    threshold: number,
    size: number
): boolean;

Parameters

threshold: Specify the threshold (in MB).

size: Specify the segment size (in KB).

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
not supported v12.1+ v12.1+ v12.1+ v12.1+

IfShowFileDialog

Return or set whether to show open/save file dialog when saving images in the buffer or loading images from a local directory.

Note: This does not affect the Android Service edition. The dialog will always show not matter what IfShowFileDialog is set to.

Syntax

IfShowFileDialog: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v6.2+ v10.0+ v11.0+ v11.0+ v12.1+ not supported

IfShowCancelDialogWhenImageTransfer

Return or set whether to show the progress of an operation with a button to cancel it.

Syntax

IfShowCancelDialogWhenImageTransfer: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v5.2+ v5.2+ v5.2+ v5.2+ v5.2+ v18.2+

Usage Notes

This API is only valid if IfShowProgressBar is set to true.


IfShowProgressBar

Return or set whether the progress bar will be displayed during any encoding, decoding, or transfer activities.

Syntax

IfShowProgressBar: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux) Android Service
v8.0+ v10.0+ v10.0+ v11.0+ v12.1+ v18.2+

ShowFileDialog()

Show the system’s save-file dialog or open-file dialog.

Syntax

ShowFileDialog(
    isSave: boolean,
    filter: string,
    filterIndex: number,
    defaultExtension: string,
    initialDirectory: string,
    allowMultiSelect: boolean,
    showOverwritePrompt: boolean,
    flag: number
): boolean;

Parameters

isSave: Whether to show a save-file dialog or an open-file dialog.

filter: The filter pattern like “JPG or *.jpg”.

filterIndex: The order of the filter. Normally, just put 0.

defaultExtension: Extension to be appended to the file name. Only valid in a save-file dialog.

initialDirectory: The initial directory that the dialog opens.

allowMultiSelect: Whether or not multiple files can be selected at the same time. Only valid in an open-file dialog.

showOverwritePrompt: Whether or not a prompt shows up when saving a file may overwrite an existing file.

flag: If set to 0, allowMultiSelect and showOverwritePrompt will be effective. Otherwise, these two parameters are ignored.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v8.0+ v10.0+ v10.0+ v11.0+ v12.1+

Usage notes

The filter pattern string consists of a combination(s) of valid file extensions with asterisk (*). For example: JPG, PNG and TIF | *.jpg;*png;*.tif . On macOS, the string is different. For example JPG, PNG , TIF . To show all files, use All Files | *.* . Do not include spaces in the pattern string.

This method will trigger OnGetFilePath event even when it fails. If multiple files are selected, the event will be called multiple times.

Example

DWObject.RegisterEvent(
    "OnGetFilePath",
    function (isSave, filesCount, index, directory, fileName) {
        alert(" directory: " + directory + "\\" + fileName);
    }
);

//On macOS
DWObject.ShowFileDialog(
    false,
    "TIF,TIFF,JPG,JPEG,PNG,PDF",
    0,
    "",
    "",
    true,
    false,
    0
);

//On Windows
DWObject.ShowFileDialog(
    false,
    "BMP,TIF,JPG,PNG,PDF|*.bmp;*.tif;*.png;*.jpg;*.pdf;*.tiff;*.jpeg",
    0,
    "",
    "",
    true,
    false,
    0
);

Print()

Export all image data in the buffer to a new browser window and use the browser’s built-in print feature to print the image(s).

Syntax

Print(useOSPrintWindow?: boolean): boolean;

Parameters

useOSPrintWindow: Whether to use the print feature of the operating system instead.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v6.0+ v10.0+ v11.0+ v11.0+ v12.1+

Usage Notes

The parameter only works in Windows Service mode.


PrintEx()

Print selected image(s).

Syntax

PrintEx(indices: number[]): boolean;

Parameters

indices: Specify the image.

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
not supported v17.0+ v17.0+ v17.0+ v17.0+

JPEGQuality

Return or set the quality for JPEG compression.

Syntax

JPEGQuality: number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v5.0+ v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

The default value of JPEGQuality property is 80.

The valid range is 0-100. The higher the JPEGQuality property, the better the quality and the bigger the size of the file.


IfTiffMultiPage

Return or set whether to append to or replace an existing TIFF file with the same name.

Syntax

IfTiffMultiPage: boolean;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v3.0+ v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

When you save a new image in the same name of an existing TIFF file:

1) If this property is true, the new image will be added to the existing file.

2) If this property is false, the new image will replace the existing file.


TIFFCompressionType

Return or set the compression type for TIFF files. Please refer to EnumDWT_TIFFCompressionType.

Syntax

TIFFCompressionType: Dynamsoft.DWT.EnumDWT_TIFFCompressionType | number;

Availability

ActiveX H5(Windows) H5(macOS/TWAIN) H5(macOS/ICA) H5(Linux)
v4.0+ v10.0+ v11.0+ v11.0+ v12.1+

Usage notes

When set to TIFF_AUTO (0), 1-bit images will be compressed in TIFF_T6 (4) while images with other bit depth will be compressed in TIFF_LZW (5).

When set to TIFF_JPEG (7), 1-bit images will be compressed in TIFF_T6 (4), color images or grey images (8-bit or higher) in TIFF_JPEG (7) standard, and other images by TIFF_LZW (5).

TIFF_T4 (3) and TIFF_FAX3 (3) are two names for the same compression type. So are TIFF_T6 (4) and TIFF_FAX4 (4).

TIFF_RLE (2), TIFF_T4 (3), TIFF_FAX3 (3) and TIFF_PACKBITS (32773) only support compression of 1-bit images. TIFF_JPEG (7) supports compression of 8-bit above color images and 8-bit grey images.

When TIFF_JPEG (7) is used, you can use JPEGQuality to further reduce the size of the TIFF file.

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest Version (18.4)
    • Version 18.3
    • Version 18.1
    • Version 18.0
    • Version 17.3
    • Version 17.2.1
    • Version 17.1.1
    • Version 17.0
    • Version 16.2
    • Version 16.1.1
    Change +