While reviewing the content in PowerPoint presentations, the comments are used to write the feedback. The comments can be added against a particular word, phrase, or anything on a PPT slide. In this article, you will learn how to add comments to PowerPoint PPT slides in C#. Moreover, we will cover how to read or remove slide comments and add their replies.
- .NET API to Work with Comments in PowerPoint
- Add Comments in PPT Slides
- Add Comment Replies in PPT Slides
- Read Comments from PPT Slides
- Remove Comments from Slides
C# .NET API to Add Comments in PowerPoint
To manipulate comments in PowerPoint presentations, we will use Aspose.Slides for .NET. It is a powerful API to create and manipulate PowerPoint presentations. You can either download API’s DLL or install it using NuGet.
PM> Install-Package Aspose.Slides.NET
Add Comments to PowerPoint PPT in C#
In PowerPoint presentations, every comment is attached with a particular author. Whereas, each comment contains some additional information such as time of creation, slide where it is added, and its position. The following are the steps to add comments to a PPT slide in C#.
- First, load the presentation file or create a new one using Presentation class.
- Then, add a new slide or get reference of an existing slide from Presentation.Slides collection.
- Add a new author using Presentation.CommentAuthors.AddAuthor(string, string) method.
- Get reference of the newly created author in an object.
- Define the position of the comment.
- Add comment using ICommentAuthor.Comments.AddComment(string, ISlide, Point, DateTime) method.
- Finally, save presentation using Presentation.Save(string, SaveFormat) method.
The following code sample shows how to add comments to PowerPoint PPT slides in C#.
The following is the screenshot of the comment we have added using the above code sample.
Add Comment Replies in PPT in C#
Aspose.Slides also allows you to add replies to the comments. A reply itself is a comment which appears as a child of an existing comment. So let’s see how to add replies to comments in PowerPoint PPT slides in C#.
- First, load the presentation file or create a new one using Presentation class.
- Then, add new slide or get reference of the existing slide from Presentation.Slides collection.
- Add a new author and get its reference in an object.
- Insert comment using ICommentAuthor.Comments.AddComment(string, ISlide, Point, DateTime) method and get returned object.
- Insert another comment in the same way and get its reference in an object.
- Set parent of the second comment using ParentComment property.
- Finally, save presentation using Presentation.Save(string, SaveFormat) method.
The following code sample shows how to add replies to comments in a PPTX slides in C#.
The following screenshot shows the output of the above code sample.
Read Comments from PPT Slides in C#
Using Aspose.Slides, you can either read comments of a particular author or all the authors. The following are the steps to read comments in PPT slides in C#.
- Load the presentation file using Presentation class.
- Loop through the list of authors using Presentation.CommentAuthors collection.
- For each author, loop through its comments using CommentAuthor.Comments property.
- Read and print comment details.
The following code sample shows how to read comments in PowerPoint PPT slides in C#.
Remove Comments from PowerPoint PPT in C#
In the previous section, you have seen how to read a comment by accessing it from the comments collection. Similarly, you can remove a comment after getting its reference. The following code sample shows how to remove comments in PowerPoint presentations in C#.
C# PowerPoint API - Get a Free License
You can work with PowerPoint PPT comments without evaluation limitations by getting a free temporary license.
Conclusion
In this article, you have learned how to add comments in PowerPoint PPT slides in C#. Moreover, we have covered how to add replies to the comments programmatically. At the end, we have demonstrated how to read or remove comments from PPT slides. You can visit the documentation to explore more about Aspose.Slides for .NET. Also, you can post your queries to our forum.