saveAsync()

Description

Saves images of specified indices in the image viewer to a local directory asynchronously.

Syntax

ImageViewerObject.io.saveAsync(filename, indices, imageType, overwritePrompt, showSaveDialog, onSaveSuccess, onSaveFailure);

Parameters

<string> fileName: specifies the name or path of the local file. If showSaveDialog is false, it should be an absolute path. Otherwise, it can be the name of the local file to be saved, or an absolute path, or an empty string or null, or an existing directory which will be treated as the initial directory of the save file dialog and it must end with '/' or '\\'. If the directory doesn't exist, it will be ignored.
<int[]> indices: specifies the indices of images in the image viewer. The index is 0-based.
<EnumImageType> imageType: specifies the format of the file you want to save as.

Image Type Enumerated Value
BMP EnumImageType.BMP
JPEG EnumImageType.JPEG
TIFF EnumImageType.TIFF
PNG EnumImageType.PNG
PDF EnumImageType.PDF

<bool> overwritePrompt: specifies whether to show the overwrite prompt. If true, users will be prompted to confirm whether or not to replace an existing file with the same name. If false, the file will be overwritten without users' confirmation.

<bool> showSaveDialog: specifies whether to show a save-file dialog.

<onsavesuccess> onSaveSuccess: the callback function triggered when the file is saved successfully.
<onsavefailure> onSaveFailure: the callback function triggered when the file failed to be saved.

Return value

void

Please refer to the function prototype onSaveSuccess or onSaveFailure.

Remarks

EnumImageType is under namespace io.

If imageType is EnumImageType.BMP/JPEG/PNG, the length of indices must be 1.

If an user clicks the cancel button on the save file dialog or overwrite prompt dialog, the method returns false, and the error code is OperationCancelled.

If the current user doesn’t have the write permission, the method returns false, and the error code is AccessDenied.

Example

function onSaveSuccess(filePath){ 
    console.log(filePath); 
}

function onSaveFailure(errorCode, errorString, filePath){
    alert(errorString + filePath); 
}
var imageViewer = DCSObject.getImageViewer(&quot;imageViewerContainer&quot;);  // Get a specified image viewer

imageViewer.io.saveAsync("C:\\temp\\", [0,1], imageViewer.io.EnumImageType.PDF, true, true, onSaveSuccess, onSaveFailure); //Save the first and second images as a multi-page PDF asynchronously.

See also

.io.save()

Is this page helpful?