Comment, CommentAuthor, CommentCollection — Aspose.Slides FOSS for Python API Reference
Aspose.Slides FOSS supports threaded slide comments. Authors are registered at the presentation level; each author can attach Comment objects to individual slides.
Package: aspose.slides_foss
CommentAuthorCollection
Access via prs.comment_authors.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
__len__ | int | Read | Number of registered comment authors. |
Methods
| Method | Signature | Description |
|---|---|---|
add_author | add_author(name, initials) -> CommentAuthor | Register a new author and return the CommentAuthor object. |
find_by_name | find_by_name(name) -> CommentAuthor | Return the author with the given name, or None. |
remove_author | remove_author(author) | Remove an author and all their comments from the presentation. |
__getitem__ | comment_authors[i] | Return the author at zero-based index i. |
__iter__ | for a in comment_authors | Iterate authors. |
CommentAuthor
Represents a named person who writes comments.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
name | str | Read/Write | Display name of the author. |
initials | str | Read/Write | Short initials shown in the comment bubble. |
comments | CommentCollection | Read | All comments written by this author across the presentation. |
CommentCollection
Collection of Comment objects belonging to an author. Access via author.comments.
| Member | Signature | Description |
|---|---|---|
add_comment | add_comment(text, slide, position, created_time) -> Comment | Add a new comment at position (PointF) on the given slide, timestamped with created_time (datetime). |
insert_comment | insert_comment(index, text, slide, position, created_time) -> Comment | Insert a comment at a specific index in the collection. |
__getitem__ | comments[i] | Return the Comment at zero-based index i. |
__len__ | len(comments) | Number of comments. |
__iter__ | for c in comments | Iterate comments. |
Comment
A single comment attached to a slide position.
Properties
| Property | Type | Access | Description |
|---|---|---|---|
text | str | Read/Write | Plain text content of the comment. |
created_time | datetime | Read/Write | Timestamp when the comment was created (UTC). |
position | PointF | Read/Write | Position of the comment anchor on the slide, in points from the top-left corner. |
slide | ISlide | Read | The slide this comment belongs to. |
author | CommentAuthor | Read | The author who wrote this comment. |
parent_comment | Comment or None | Read/Write | Parent comment for threaded replies. None if this is a top-level comment. |
Methods
| Method | Signature | Description |
|---|---|---|
remove | remove() | Remove this comment and all its direct replies from the slide. Changes are persisted immediately. |
ModernComment
ModernComment (PPTX modern comment type) shares the same interface as Comment and is returned for slides that use the modern comment XML format. Use it identically.
Usage Example
Add comments and read them back
from datetime import datetime, timezone
import aspose.slides_foss as slides
from aspose.slides_foss import ShapeType
from aspose.slides_foss.drawing import PointF
from aspose.slides_foss.export import SaveFormat
with slides.Presentation() as prs:
slide = prs.slides[0]
# Add a shape
shape = slide.shapes.add_auto_shape(ShapeType.RECTANGLE, 100, 100, 400, 80)
shape.add_text_frame("Slide content")
# Register an author
author = prs.comment_authors.add_author("Jane Smith", "JS")
# Add a top-level comment
ts = datetime(2025, 6, 1, 10, 0, 0, tzinfo=timezone.utc)
comment = author.comments.add_comment(
"Please update the chart data before the meeting.",
slide,
PointF(150.0, 120.0),
ts,
)
# Add a reply
reply_ts = datetime(2025, 6, 1, 11, 30, 0, tzinfo=timezone.utc)
reply = author.comments.add_comment(
"Done — data refreshed from Q2 report.",
slide,
PointF(150.0, 120.0),
reply_ts,
)
reply.parent_comment = comment
prs.save("comments-demo.pptx", SaveFormat.PPTX)
# Reading comments back
with slides.Presentation("comments-demo.pptx") as prs:
for author in prs.comment_authors:
print(f"Author: {author.name}")
for c in author.comments:
parent_info = f" (reply to: {c.parent_comment.text[:20]}...)" if c.parent_comment else ""
print(f" [{c.created_time}] {c.text}{parent_info}")