editDocument()

Description

Opens a specified document in the document editor (specified by its id) for editing.

Syntax

ImageViewerObject.image.editDocument(documentEditorContainerId, index);

Parameters

<string> documentEditorContainerId: the container id of a document editor.
<int> index: specifies the index of a document in the buffer. The index is 0-based.

Return value

bool

When false is returned, check getErrorCode() or getErrorString() for error information.

Remarks

The index is 0 based.

The document will be fit to the document editor window and the zoom value will be updated automatically.

The document editor container must be a DIV element. If the DIV element with the specified id doesn't exist, when you check getErrorString(), you will get an error "The object [object name] does not exist.".

When there is a document already being edited in the specified document editor, the event ondiscardmodified will be fired. If this event returns true, when you check getErrorString(), you will get an error "The document cannot be edited when another document is being edited in the document editor.".

If the document you are trying to edit is already in the editor, when you check getErrorString(), you will get an error "The document is being edited now.".

If you are trying to open an image in the editor, when you check getErrorString(), you will get an error "You are trying to open an image in the document editor.".

Example

       if (DCSObject) {
           var imageviewer = DCSObject.getImageViewer("ImageViewerContainer");  // Gets a specified image viewer
           DCSObject.addDocumentEditor("DocumentEditorContainer"); //Adds a document editor
           imageviewer.image.editDocument("DocumentEditorContainer", 0);
       }
       

See also

getImageViewer()