public class Comment extends java.lang.Object implements IComment
Represents a comment on a slide.
This example shows you how to add a comment to a slide in a PowerPoint presentation.// Instantiates the Presentation class Presentation presentation = new Presentation(); try { // Adds an empty slide presentation.getSlides().addEmptySlide(presentation.getLayoutSlides().get_Item(0)); // Adds an author ICommentAuthor author = presentation.getCommentAuthors().addAuthor("Jawad", "MF"); // Sets the position for comments Point2D.Float point = new Point2D.Float(); point.x = 0.2f; point.y = 0.2f; // Adds slide comment for an author on slide 1 author.getComments().addComment("Hello Jawad, this is slide comment", presentation.getSlides().get_Item(0), point, new Date()); // Adds slide comment for an author on slide 2 author.getComments().addComment("Hello Jawad, this is second slide comment", presentation.getSlides().get_Item(1), point, new Date()); // Save the PowerPoint Presentation file presentation.save("Comments_out.pptx", SaveFormat.Pptx); } finally { if (presentation != null) presentation.dispose(); }This example shows you how to access an existing comment on a slide in a PowerPoint presentation.// Instantiates the Presentation class Presentation presentation = new Presentation("Comments1.pptx"); try { // Iterate CommentAuthors for (ICommentAuthor commentAuthor : presentation.getCommentAuthors()) { CommentAuthor author = (CommentAuthor) commentAuthor; // Iterate Comments for (IComment comment1 : author.getComments()) { Comment comment = (Comment) comment1; System.out.println("ISlide :" + comment.getSlide().getSlideNumber() + " has comment: " + comment.getText() + " with Author: " + comment.getAuthor().getName() + " posted on time :" + comment.getCreatedTime().toString() + "\n"); } } } finally { if (presentation != null) presentation.dispose(); }This example shows you how to add comments and get replies to them.// Instantiates the Presentation class Presentation pres = new Presentation(); try { // Adds a comment ICommentAuthor author1 = pres.getCommentAuthors().addAuthor("Author_1", "A.A."); IComment comment1 = author1.getComments().addComment("comment1", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); // Adds a reply to comment1 ICommentAuthor author2 = pres.getCommentAuthors().addAuthor("Autror_2", "B.B."); IComment reply1 = author2.getComments().addComment("reply 1 for comment 1", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); reply1.setParentComment(comment1); // Adds another reply to comment1 IComment reply2 = author2.getComments().addComment("reply 2 for comment 1", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); reply2.setParentComment(comment1); // Adds a reply to existing reply IComment subReply = author1.getComments().addComment("subreply 3 for reply 2", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); subReply.setParentComment(reply2); IComment comment2 = author2.getComments().addComment("comment 2", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); IComment comment3 = author2.getComments().addComment("comment 3", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); IComment reply3 = author1.getComments().addComment("reply 4 for comment 3", pres.getSlides().get_Item(0), new Point2D.Float(10, 10), new Date()); reply3.setParentComment(comment3); // Displays the comments hierarchy on console ISlide slide = pres.getSlides().get_Item(0); IComment[] comments = slide.getSlideComments(null); for (int i = 0; i < comments.length; i++) { IComment comment = comments[i]; while (comment.getParentComment() != null) { System.out.println("\t"); comment = comment.getParentComment(); } System.out.println(comments[i].getAuthor().getName() + " : " + comments[i].getText()); } pres.save("parent_comment.pptx",SaveFormat.Pptx); // Removes comment1 and all replies to it comment1.remove(); pres.save("remove_comment.pptx", SaveFormat.Pptx); } finally { if (pres != null) pres.dispose(); }
| Modifier and Type | Method and Description |
|---|---|
ICommentAuthor |
getAuthor()
Returns the author of a comment.
|
java.util.Date |
getCreatedTime()
Returns or sets the time of a comment creation.
|
com.aspose.slides.IDOMObject |
getParent_Immediate()
Returns Parent_Immediate object.
|
IComment |
getParentComment()
Gets or sets parent comment.
|
java.awt.geom.Point2D.Float |
getPosition()
Returns or sets the position of a comment on a slide.
|
ISlide |
getSlide()
Returns or sets the parent slide of a comment.
|
java.lang.String |
getText()
Returns or sets the plain text of a slide comment.
|
void |
remove()
Removes comment and all its replies from the parent collection.
|
void |
setCreatedTime(java.util.Date value)
Returns or sets the time of a comment creation.
|
void |
setParentComment(IComment value)
Gets or sets parent comment.
|
void |
setPosition(java.awt.geom.Point2D.Float value)
Returns or sets the position of a comment on a slide.
|
void |
setText(java.lang.String value)
Returns or sets the plain text of a slide comment.
|
public final java.lang.String getText()
Returns or sets the plain text of a slide comment.
Read/write String.
public final void setText(java.lang.String value)
Returns or sets the plain text of a slide comment.
Read/write String.
public final java.util.Date getCreatedTime()
Returns or sets the time of a comment creation.
Setting this property to java.util.Date(Long.MIN_VALUE) means no comment time is set.
Read/write Date.
getCreatedTime in interface ICommentpublic final void setCreatedTime(java.util.Date value)
Returns or sets the time of a comment creation.
Setting this property to java.util.Date(Long.MIN_VALUE) means no comment time is set.
Read/write Date.
setCreatedTime in interface ICommentpublic final ISlide getSlide()
Returns or sets the parent slide of a comment.
Read-only ISlide.
public final ICommentAuthor getAuthor()
Returns the author of a comment.
Read-only ICommentAuthor.
public final java.awt.geom.Point2D.Float getPosition()
Returns or sets the position of a comment on a slide.
Read/write Point2D.Float.
getPosition in interface ICommentpublic final void setPosition(java.awt.geom.Point2D.Float value)
Returns or sets the position of a comment on a slide.
Read/write Point2D.Float.
setPosition in interface ICommentpublic final void remove()
Removes comment and all its replies from the parent collection.
remove in interface ICommentPptxEditException - Thrown if comment is already removedpublic final IComment getParentComment()
Gets or sets parent comment.
Read/write IComment.
getParentComment in interface ICommentPptxEditException - Thrown when setting the value leads to a circular referencepublic final void setParentComment(IComment value)
Gets or sets parent comment.
Read/write IComment.
setParentComment in interface ICommentPptxEditException - Thrown when setting the value leads to a circular referencepublic com.aspose.slides.IDOMObject getParent_Immediate()
Returns Parent_Immediate object.
Read-only IDOMObject.
Copyright © 2004-2025 Aspose Pty Ltd. All Rights Reserved.