Api

class Api

Description

Base class.

Instance Methods

OpenFile(binaryFile, fields)

Opens a file with fields.

GetFields(): string[]

Returns all fields as a text.

InsertAndReplaceContentControls(arrDocuments): ContentControlProperties[]

Inserts the content control containing data.

RemoveContentControls(arrDocuments)

Removes several content controls.

GetAllContentControls(): ContentControl[]

Returns information about all the content controls that have been added to the page.

RemoveContentControl(InternalId): ContentControlParentPr

Removes the currently selected content control retaining all its contents.

GetCurrentContentControl(): string

Returns an identifier of the selected content control (i.e. the content control where the mouse cursor is currently positioned).

GetCurrentContentControlPr(contentFormat): ContentControlProperties

Returns the current content control properties.

SelectContentControl(id)

Selects the specified content control.

MoveCursorToContentControl(id, isBegin)

Moves a cursor to the specified content control.

RemoveSelectedContent()

Removes the selected content from the document.

AddComment(oCommentData): string | "null"

Adds a comment to the document.

MoveCursorToStart(isMoveToMainContent)

Moves a cursor to the beginning of the current editing area (document body, footer/header, footnote, or autoshape).

MoveCursorToEnd(isMoveToMainContent)

Moves a cursor to the end of the current editing area (document body, footer/header, footnote, or autoshape).

SearchAndReplace(oProperties, oProperties.searchString, oProperties.replaceString, oProperties.matchCase)

Finds and replaces the text.

SearchNext(oProperties, oProperties.searchString, oProperties.matchCase, isForward): boolean

Finds and selects the next occurrence of the text starting at the current position.

GetFileHTML(): string

Returns file content in the HTML format.

GetAllComments(): comment[]

Returns all the comments from the document.

RemoveComments(arrIds)

Removes the specified comments.

ChangeComment(sId, oCommentData)

Changes the specified comment.

MoveToComment(sId)

Moves a cursor to the specified comment.

SetDisplayModeInReview(sMode)

Sets the display mode for track changes.

AddContentControl(type, commonPr): ContentControl

Adds an empty content control to the document.

AddContentControlCheckBox(checkBoxPr, commonPr)

Adds an empty content control checkbox to the document.

AddContentControlPicture(commonPr)

Adds an empty content control picture to the document.

AddContentControlList(type, List, commonPr)

Adds an empty content control list to the document.

AddContentControlDatePicker(datePickerPr, commonPr)

Adds an empty content control datepicker to the document.

GetAllOleObjects(sPluginId): OLEObjectData[]

Returns all OLE object data for objects which can be opened by the specified plugin.

RemoveOleObject(sInternalId)

Removes the OLE object from the document by its internal ID.

RemoveOleObjects(arrObjects)

Removes several OLE objects from the document by their internal IDs.

SelectOleObject(id)

Selects the specified OLE object.

InsertOleObject(NewObject, bSelect)

Inserts the OLE object at the current document position.

ChangeOleObject(ObjectData)

Changes the OLE object with the InternalId specified in OLE object data.

ChangeOleObjects(arrObjectData)

Changes multiple OLE objects with the InternalIds specified in OLE object data.

AcceptReviewChanges(isAll)

Accepts review changes.

RejectReviewChanges(isAll)

Rejects review changes.

MoveToNextReviewChange(isForward)

Navigates through the review changes.

GetAllAddinFields(): AddinFieldData[]

Returns all addin fields from the current document.

UpdateAddinFields(arrData)

Updates the addin fields with the specified data.

AddAddinField(data)

Creates a new addin field with the data specified in the request.

RemoveFieldWrapper(fieldId)

Removes a field wrapper, leaving only the field content.

SetEditingRestrictions(restrictions)

Sets the document editing restrictions.

GetCurrentWord(type): string

Returns the current word.

ReplaceCurrentWord(replaceString, type)

Replaces the current word with the specified string.

GetCurrentSentence(type): string

Returns the current sentence.

ReplaceCurrentSentence(replaceString, type)

Replaces the current sentence with the specified string.

Undo()

Undo the user's last action.

Redo()

Revert the user's last undone action.

CanUndo()

Check if it possible to undo the user's last action.

CanRedo()

Check if it possible to revert the user's last undone action.

GetAllForms(): ContentControl[]

Returns information about all the forms that have been added to the document.

GetFormsByTag(tag): ContentControl[]

Returns information about all the forms that have been added to the document with specified tag.

SetFormValue(internalId, value)

Sets a value to the specified form.

GetFormValue(internalId): "null" | string | boolean

Returns a value of the specified form.

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).