Comment / CommentAuthor — Aspose.Slides FOSS for Java API Reference
The Comment and CommentAuthor classes represent slide comments and their authors. They implement IComment and ICommentAuthor respectively.
Package: org.aspose.slides.foss
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.ICommentAuthor;
import org.aspose.slides.foss.ICommentAuthorCollection;
import org.aspose.slides.foss.export.SaveFormat;
import org.aspose.slides.foss.drawing.PointF;Comment
public class Comment implements ICommentConstructor
| Signature | Description |
|---|---|
Comment(String text, ICommentAuthor author, ISlide slide, PointF position, LocalDateTime createdTime) | Create a new comment. |
Properties
| Property | Type | Access | Description |
|---|---|---|---|
getText() / setText(String) | String | Read/Write | Comment text. |
getAuthor() | ICommentAuthor | Read | The comment author. |
getSlide() | ISlide | Read | Slide this comment is on. |
getPosition() | PointF | Read | Position on the slide. |
getCreatedTime() | LocalDateTime | Read | Creation timestamp. |
getParentComment() | Optional<IComment> | Read | Parent comment for replies. |
setParentComment(IComment) | void | Write | Set parent comment. |
Methods
| Method | Returns | Description |
|---|---|---|
remove() | void | Remove this comment. |
CommentAuthor
public class CommentAuthor implements ICommentAuthorConstructor
| Signature | Description |
|---|---|
CommentAuthor(String name, String initials, int id) | Create a new comment author. |
Properties
| Property | Type | Description |
|---|---|---|
getName() | String | Author name. |
getInitials() | String | Author initials. |
getId() | int | Author identifier. |
getComments() | ICommentCollection | Comments by this author. |
Usage Examples
Add a Comment to a Slide
import org.aspose.slides.foss.Presentation;
import org.aspose.slides.foss.ISlide;
import org.aspose.slides.foss.ICommentAuthor;
import org.aspose.slides.foss.ICommentAuthorCollection;
import org.aspose.slides.foss.export.SaveFormat;
import org.aspose.slides.foss.drawing.PointF;
import java.time.LocalDateTime;
Presentation prs = new Presentation();
ICommentAuthorCollection authors = prs.getCommentAuthors();
ICommentAuthor author = authors.addAuthor("John", "J");
ISlide slide = prs.getSlides().get(0);
slide.getSlideComments(null); // read existing comments
// Add comment via the author's comment collection
author.getComments().addComment(
"Review this slide", slide, new PointF(100, 100), LocalDateTime.now());
prs.save("commented.pptx", SaveFormat.PPTX);