httpDownloadDocumentAsync()

Description

Downloads a document from the HTTP server into an image viewer asynchronously.

Syntax

ImageViewerObject.io.httpDownloadDocumentAsync(url, onHttpDownloadSuccess, onHttpDownloadFailure [, onHttpDownloading]));

Parameters

<string> url: specifies the URL to download the file.
<onHttpDownloadSuccess function> onHttpDownloadSuccess: callback function triggered when the file is downloaded successfully.
<onHttpDownloadFailure function> onHttpDownloadFailure: callback function triggered when the file failed to be downloaded.
<onhttpdownloading function> optional onHttpDownloading: callback function triggered during downloading the document.

Please refer to the function prototype onHttpDownloadSuccess or onHttpDownloadFailure. or onHttpDownloading.

Return value

void

Remarks

This method only supports downloading BMP, JPEG, PNG, TIFF and PDF files.

When the document fails to be loaded into the viewer, please check errorCode, errorString and httpResponse in failure callback function for more information.

Previously selected documents/images will be deselected and the newly loaded document will be selected automatically.

When the image buffer is full, that is to say, count equals capacity, the downloaded document will not be imported into the image buffer.

Example

/****Get image01.png from: http://www.dynamsoft.com/images/image01.png****/
var imageviewer = DCSObject.getImageViewer ('ImageViewerContainer');  // Gets a specified image viewer
imageviewer.io.httpDownloadDocumentAsync('www.dynamsoft.com/images/image01.png', onHttpDownloadSuccess, onHttpDownloadFailure, onHttpDownloading);

function onHttpDownloadSuccess () {
    console.log('successful'); 
}

function onHttpDownloadFailure (errorCode, errorString, httpResponse) {
    console.log('ErrorCode: ' + errorCode+ 'ErrorString: ' + errorString + 'HTTPResponseString: ' + httpResponse);
}

function onHttpDownloading (percentage) {

}

See also

.io.httpDownloadDocument()