Api

class Api

Description

Base class

Instance Methods

GetDocument(): ApiDocument

Returns the main document.

CreateParagraph(): ApiParagraph

Creates a new paragraph.

CreateRange(oElement, nStart, nEnd): ApiRange | "null"

Creates an element range.

CreateTable(nCols, nRows): ApiTable

Creates a new table with a specified number of rows and columns.

CreateRun(): ApiRun

Creates a new smaller text block to be inserted to the current paragraph or table.

CreateHyperlink(sLink, sDisplay, sScreenTipText): ApiHyperlink

Creates a new hyperlink text block to be inserted to the current paragraph or table.

CreateImage(sImageSrc, nWidth, nHeight): ApiImage

Creates an image with the parameters specified.

CreateShape(sType, nWidth, nHeight, oFill, oStroke): ApiShape

Creates a shape with the parameters specified.

CreateChart(sType, aSeries, aSeriesNames, aCatNames, nWidth, nHeight, nStyleIndex, aNumFormats): ApiChart

Creates a chart with the parameters specified.

CreateOleObject(sImageSrc, nWidth, nHeight, sData, sAppId): ApiOleObject

Creates an OLE object with the parameters specified.

CreateRGBColor(r, g, b): ApiRGBColor

Creates an RGB color setting the appropriate values for the red, green and blue color components.

CreateSchemeColor(sSchemeColorId): ApiSchemeColor

Creates a complex color scheme selecting from one of the available schemes.

CreatePresetColor(sPresetColor): ApiPresetColor

Creates a color selecting it from one of the available color presets.

CreateSolidFill(oUniColor): ApiFill

Creates a solid fill to apply to the object using a selected solid color as the object background.

CreateLinearGradientFill(aGradientStop, Angle): ApiFill

Creates a linear gradient fill to apply to the object using the selected linear gradient as the object background.

CreateRadialGradientFill(aGradientStop): ApiFill

Creates a radial gradient fill to apply to the object using the selected radial gradient as the object background.

CreatePatternFill(sPatternType, BgColor, FgColor): ApiFill

Creates a pattern fill to apply to the object using the selected pattern as the object background.

CreateBlipFill(sImageUrl, sBlipFillType): ApiFill

Creates a blip fill to apply to the object using the selected image as the object background.

CreateNoFill(): ApiFill

Creates no fill and removes the fill from the element.

CreateStroke(nWidth, oFill): ApiStroke

Creates a stroke adding shadows to the element.

CreateGradientStop(oUniColor, nPos): ApiGradientStop

Creates a gradient stop used for different types of gradients.

CreateNumbering(sType, nStartAt): ApiBullet

Creates a bullet for a paragraph with the numbering character or symbol specified with the sType parameter.

CreateInlineLvlSdt(): ApiInlineLvlSdt

Creates a new inline container.

CreateBlockLvlSdt(): ApiBlockLvlSdt

Creates a new block level container.

Save()

Saves changes to the specified document.

LoadMailMergeData(aList): boolean

Loads data for the mail merge.

GetMailMergeTemplateDocContent(): ApiDocumentContent

Returns the mail merge template document.

GetMailMergeReceptionsCount(): number

Returns the mail merge receptions count.

ReplaceDocumentContent(oApiDocumentContent)

Replaces the main document content with another document content.

MailMerge(nStartIndex, nEndIndex): boolean

Starts the mail merge process.

FromJSON(sMessage)

Converts the specified JSON object into the Document Builder object of the corresponding type.

AddComment(oElement, sText, sAuthor, sUserId): ApiComment

Adds a comment to the specifed document element or array of Runs.

attachEvent(eventName, callback)

Subscribes to the specified event and calls the callback function when the event fires.

detachEvent(eventName)

Unsubscribes from the specified event.

ReplaceTextSmart(arrString, sParaTab, sParaNewLine)

Replaces each paragraph (or text in cell) in the select with the corresponding text from an array of strings.

ConvertDocument(sConvertType, bHtmlHeadings, bBase64img, bDemoteHeadings, bRenderHTMLTags): string

Converts a document to Markdown or HTML text.

CreateTextPr(): ApiTextPr

Creates the empty text properties.

CreateWordArt(oTextPr, sText, sTransform, oFill, oStroke, nRotAngle, nWidth, nHeight): ApiDrawing

Creates a Text Art object with the parameters specified.

GetFullName(): string

Returns the full name of the currently opened file.

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