ApiDocument

class ApiDocument extends ApiDocumentContent

Description

Class representing a document.

Instance Methods

GetClassType(): document

Returns a type of the ApiDocument class.

CreateNewHistoryPoint()

Creates a new history point.

GetStyle(sStyleName): ApiStyle

Returns a style by its name.

CreateStyle(sStyleName, sType): ApiStyle

C.

GetDefaultStyle(sStyleType): ApiStyle

Returns the default style parameters for the specified document element.

GetDefaultTextPr(): ApiTextPr

Returns a set of default properties for the text run in the current document.

GetDefaultParaPr(): ApiParaPr

Returns a set of default paragraph properties in the current document.

GetFinalSection(): ApiSection

Returns the document final section.

CreateSection(oParagraph): ApiSection | "null"

C.

SetEvenAndOddHdrFtr(isEvenAndOdd)

Specifies whether sections in this document will have different headers and footers for even and odd pages (one header/footer for odd pages and another header/footer for even pages).

CreateNumbering(sType): ApiNumbering

Creates an abstract multilevel numbering with a specified type.

InsertContent(arrContent, isInline, oPr): boolean

Inserts an array of elements into the current position of the document.

GetCommentsReport(): CommentReport

Returns a report about all the comments added to the document.

GetReviewReport(): ReviewReport

Returns a report about every change which was made to the document in the review mode.

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

Finds and replaces the text.

GetAllContentControls(): ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Returns a list of all the content controls from the document.

GetTagsOfAllContentControls(): String[]

Returns a list of all tags that are used for all content controls in the document.

GetTagsOfAllForms(): String[]

Returns a list of all tags that are used for all forms in the document.

GetContentControlsByTag(sTag): ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Returns a list of all content controls in the document with the specified tag name.

GetFormsByTag(sTag): ApiBlockLvlSdt[] | ApiInlineLvlSdt[]

Returns a list of all forms in the document with the specified tag name.

GetFormsData(): FormData[]

R.

SetFormsData(arrData)

Sets the data to the specified forms.

SetTrackRevisions(isTrack)

Sets the change tracking mode.

IsTrackRevisions(): boolean

Checks if change tracking mode is enabled or not.

GetRange(Start, End): ApiRange

Returns a Range object that represents the part of the document contained in the specified document.

GetRangeBySelect(): ApiRange | "null"

Returns a range object by the current selection.

Last(): DocumentElement

Returns the last document element.

DeleteBookmark(sName): boolean

Removes a bookmark from the document, if one exists.

GetBookmarkRange(sName): ApiRange | "null"

Returns a bookmark range.

GetSections(): ApiSection[]

Returns a collection of section objects in the document.

GetAllTablesOnPage(nPage): ApiTable[]

R.

AddDrawingToPage(oDrawing, nPage, x, y): boolean

A.

RemoveSelection()

Removes the current selection.

Search(sText, isMatchCase): ApiRange[]

S.

ToMarkdown(bHtmlHeadings, bBase64img, bDemoteHeadings, bRenderHTMLTags): string

Converts a document to Markdown.

ToHtml(bHtmlHeadings, bBase64img, bDemoteHeadings, bRenderHTMLTags): string

Converts a document to HTML.

InsertWatermark(sText, bIsDiagonal): ApiDrawing

Inserts a watermark on each document page.

GetWatermarkSettings(): ApiWatermarkSettings

Returns the watermark settings in the current document.

SetWatermarkSettings(Settings): ApiDrawing

Sets the watermark settings in the current document.

RemoveWatermark()

Removes a watermark from the current document.

UpdateAllTOC(bOnlyPageNumbers)

Updates all tables of contents in the current document.

UpdateAllTOF(bOnlyPageNumbers)

Updates all tables of figures in the current document.

UpdateAllFields(bBySelection)

Updates all fields in the document.

ToJSON(bWriteDefaultTextPr, bWriteDefaultParaPr, bWriteTheme, bWriteSectionPr, bWriteNumberings, bWriteStyles): JSON

Converts the ApiDocument object into the JSON object.

GetAllForms(): ApiForm[]

Returns all existing forms in the document.

ClearAllFields()

Clears all forms in the document.

SetFormsHighlight(r, g, b, bNone)

Sets the highlight to the forms in the document.

GetAllComments(): ApiComment[]

Returns all comments from the current document.

GetCommentById(sId): ApiComment

Returns a comment from the current document by its ID.

GetAllNumberedParagraphs(): ApiParagraph[]

Returns all numbered paragraphs from the current document.

GetAllHeadingParagraphs(): ApiParagraph[]

Returns all heading paragraphs from the current document.

GetFootnotesFirstParagraphs(): ApiParagraph[]

Returns the first paragraphs from all footnotes in the current document.

GetEndNotesFirstParagraphs(): ApiParagraph[]

Returns the first paragraphs from all endnotes in the current document.

GetAllCaptionParagraphs(sCaption): ApiParagraph[]

Returns all caption paragraphs of the specified type from the current document.

AcceptAllRevisionChanges()

Accepts all changes made in review mode.

RejectAllRevisionChanges()

Rejects all changes made in review mode.

GetAllBookmarksNames(): string[]

Returns an array with names of all bookmarks in the current document.

GetSelectedDrawings(): ApiShape[] | ApiImage[] | ApiChart[] | ApiDrawing[]

Returns all the selected drawings in the current document.

ReplaceCurrentImage(sImageUrl, Width, Height)

Replaces the current image with an image specified.

ReplaceDrawing(oOldDrawing, oNewDrawing, bSaveOldDrawingPr): boolean

Replaces a drawing with a new drawing.

AddFootnote(): ApiDocumentContent

Adds a footnote for the selected text (or the current position if the selection doesn't exist).

AddEndnote(): ApiDocumentContent

Adds an endnote for the selected text (or the current position if the selection doesn't exist).

SetControlsHighlight(r, g, b, bNone)

Sets the highlight to the content controls from the current document.

AddTableOfContents(oTocPr)

A.

AddTableOfFigures(oTofPr, bReplace): boolean

Adds a table of figures to the current document.

GetStatistics(): object

Returns the document statistics represented as an object with the following parameters: PageCount - number of pages; WordsCount - number of words; ParagraphCount - number of paragraphs; SymbolsCount - number of symbols; SymbolsWSCount - number of symbols with spaces.

GetPageCount(): number

R.

GetAllStyles(): ApiStyle[]

Returns all styles of the current document.

GetDocumentInfo(): object

Returns the document information: Application .

GetCurrentWord(sWordPart): string

Returns the current word or part of the current word.

ReplaceCurrentWord(sReplace, sPart): boolean

Replace the current word or part of the current word with the specified text.

SelectCurrentWord(): object

Selects the current word if it possible.

AddComment(sText, sAuthor, sUserId): ApiComment

Adds a comment to the current selection of the document, or to the current word if there is no text selection.

GetCurrentSentence(sPart): string

Returns the current sentence or part of the current sentence.

ReplaceCurrentSentence(sReplace, sPart): boolean

Replace the current sentence or part of the current sentence with the specified text.

AddMathEquation(sText, sFormat)

Add a math equation.

GetElementsCount()

Returns a number of elements in the current document.

GetElement(nPos)

Returns an element by its position in the document.

AddElement(nPos, oElement)

Adds a paragraph or a table or a blockLvl content control using its position in the document content.

Push(oElement)

Pushes a paragraph or a table to actually add it to the document.

RemoveAllElements()

R.

RemoveElement(nPos)

Removes an element using the position specified.

GetContent(bGetCopies)

Returns an array of document elements from the current ApiDocumentContent object.

GetAllDrawingObjects()

Returns a collection of drawing objects from the document content.

GetAllShapes()

Returns a collection of shape objects from the document content.

GetAllImages()

Returns a collection of image objects from the document content.

GetAllCharts()

Returns a collection of chart objects from the document content.

GetAllOleObjects()

Returns a collection of OLE objects from the document content.

GetAllParagraphs()

Returns an array of all paragraphs from the current document content.

GetAllTables()

Returns an array of all tables from the current document content.

Extends

ApiDocumentContent

Class representing a container for paragraphs and tables.

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