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

Syntax, indices, imageType, overwritePrompt, showSaveDialog);


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

Return value


A plain object containing the result of the save task.

success: (type: bool)
Whether the file is saved successfully.
filename: (type: string)
The absolute path that a user wants to save to.
For example:
success: true,
filename: "C:/use/document/abc.jpg"


EnumImageType is under namespace io.

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

If a 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.


var imageViewer = DCSObject.getImageViewer(&quot;imageViewerContainer&quot;);  // Get a specified image viewer"C:\\temp\\ImageData.pdf", [0,1],, true, false); //Save the first and second images as a multi-page PDF synchronously.
//"", [0,1],, true, true);

See also


Is this page helpful?