ApiComment

new ApiComment()

Class representing a comment.

Methods

Name Description
AddReply

Adds a reply to a comment.

Delete

Deletes the current comment from the document.

GetAuthorName

Returns the comment author's name.

GetClassType

Returns a type of the ApiComment class.

GetId

Returns the current comment ID. If the comment doesn't have an ID, null is returned.

GetQuoteText

Returns the quote text of the current comment.

GetRepliesCount

Returns a number of the comment replies.

GetReply

Returns the specified comment reply.

GetText

Returns the comment text.

GetTime

Returns the timestamp of the comment creation in the current time zone format.

GetTimeUTC

Returns the timestamp of the comment creation in UTC format.

GetUserId

Returns the user ID of the comment author.

IsSolved

Checks if a comment is solved or not.

RemoveReplies

Removes the specified comment replies.

SetAuthorName

Sets the comment author's name.

SetSolved

Marks a comment as solved.

SetText

Sets the comment text.

SetTime

Sets the timestamp of the comment creation in the current time zone format.

SetTimeUTC

Sets the timestamp of the comment creation in UTC format.

SetUserId

Sets the user ID to the comment author.

Example

Copy code
builder.CreateFile("docx");
var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
oParagraph.AddText("This is just a sample text");
Api.AddComment(oParagraph, "comment", "John Smith");
var aComments = oDocument.GetAllComments();
aComments[0].SetTimeUTC("1672247153658");
aComments[0].SetUserId("uid-1");
aComments[0].AddReply("reply1", "Mark Potato", "uid-2", 0);
var sType = aComments[0].GetClassType();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Class type: " + sType);
oDocument.Push(oParagraph);
var sTimeUTC = aComments[0].GetTimeUTC();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The timestamp of comment creation: " + sTimeUTC);
oDocument.Push(oParagraph);
var sAuthor = aComments[0].GetAuthorName();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Comment author name: " + sAuthor);
oDocument.Push(oParagraph);
var sQuoteText = aComments[0].GetQuoteText();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Comment quote text: " + sQuoteText);
oDocument.Push(oParagraph);
var sText = aComments[0].GetText();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Comment text: " + sText);
oDocument.Push(oParagraph);
var sUserId = aComments[0].GetUserId();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Comment user ID: " + sUserId);
oDocument.Push(oParagraph);
aComments[0].SetSolved(true);
var bSolved = aComments[0].IsSolved();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("The comment is solved: " + bSolved);
oDocument.Push(oParagraph);
var nReplies = aComments[0].GetRepliesCount();
oParagraph = Api.CreateParagraph();
oParagraph.AddText("Number of comment replies: " + nReplies);
oDocument.Push(oParagraph);
var oCommentReply = aComments[0].GetReply(0);
oParagraph = Api.CreateParagraph();
oParagraph.AddText("First comment reply: " + oCommentReply.GetText());
oDocument.Push(oParagraph);
builder.SaveFile("docx", "ApiComment.docx");
builder.CloseFile();

Resulting document