Get Started
Usage API
More information

AddComment

AddComment(oElement, Comment, Autor) → { bool }

Add a comment to the desired element or array of Runs.

Parameters:

Name Type Description
oElement Array.<ApiRun> | ApiParagraph | ApiDocument

May be Document, Paragraph or Run[].

Comment string

The comment text.

Autor string

The author's name (not obligatory).

Returns:

Type
bool

Example

Copy code
builder.CreateFile("docx");
oDocument = Api.GetDocument();
oParagraph = oDocument.GetElement(0);
oParagraph.AddText("ONLYOFFICE Document Builder");
Api.AddComment(oParagraph, "ONLYOFFICE for developers", "Jane");
builder.SaveFile("docx", "AddComment.docx");
builder.CloseFile();

Resulting document