How to Add Comments to PowerPoint in .NET
Aspose.Slides FOSS for .NET supports two annotation mechanisms:
- Threaded comments: attached to a slide at a specific position, visible in PowerPoint’s Review pane
- Speaker notes: per-slide text visible in Presenter View and the Notes pane
Prerequisites
dotnet add package Aspose.Slides.FossAdd a Comment
Comments belong to an author object. Create an author first, then add comments through author.Comments:
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
// Create a comment author with name and initials
var author = prs.CommentAuthors.AddAuthor("Jane Smith", "JS");
var slide = prs.Slides[0];
// Add a comment at (2.0, 2.0) inches from the slide top-left corner
author.Comments.AddComment(
"Please review the figures on this slide",
slide,
new PointF(2.0f, 2.0f),
DateTime.Now
);
prs.Save("commented.pptx", SaveFormat.Pptx);The PointF coordinates are in inches from the top-left of the slide. Multiple calls to AddComment() create a threaded comment chain under the same author.
Multiple Authors and Comments
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Drawing;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
var author1 = prs.CommentAuthors.AddAuthor("Alice Brown", "AB");
var author2 = prs.CommentAuthors.AddAuthor("Bob Davis", "BD");
var slide = prs.Slides[0];
author1.Comments.AddComment(
"Initial draft: needs revision",
slide, new PointF(1.0f, 1.0f), DateTime.Now
);
author2.Comments.AddComment(
"Approved after changes",
slide, new PointF(3.0f, 1.0f), DateTime.Now
);
prs.Save("multi-author.pptx", SaveFormat.Pptx);Read Comments from an Existing File
using Aspose.Slides.Foss;
using var prs = new Presentation("commented.pptx");
foreach (var author in prs.CommentAuthors)
{
Console.WriteLine($"Author: {author.Name} ({author.Initials})");
foreach (var comment in author.Comments)
{
Console.WriteLine($" Slide: {comment.Text}");
}
}Add Speaker Notes to a Slide
Speaker notes are added through slide.NotesSlideManager:
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;
using var prs = new Presentation();
var slide = prs.Slides[0];
slide.Shapes.AddAutoShape(
ShapeType.Rectangle, 50, 50, 600, 300
).AddTextFrame("Main slide content");
// Create the notes slide and write text
var notes = slide.NotesSlideManager.AddNotesSlide();
notes.NotesTextFrame.Text =
"Mention the Q3 revenue increase. Emphasize the 24% YoY growth.";
prs.Save("with-notes.pptx", SaveFormat.Pptx);Add Notes to Multiple Slides
using Aspose.Slides.Foss;
using Aspose.Slides.Foss.Export;
string[] noteTexts = {
"Opening: introduce the agenda and set expectations.",
"Key metrics: emphasize Q4 results and growth trajectory.",
"Closing: summarize and call to action.",
};
using var prs = new Presentation();
var layout = prs.Slides[0].LayoutSlide;
prs.Slides.AddEmptySlide(layout);
prs.Slides.AddEmptySlide(layout);
for (int i = 0; i < prs.Slides.Count; i++)
{
var slide = prs.Slides[i];
slide.Shapes.AddAutoShape(
ShapeType.Rectangle, 50, 50, 600, 300
).AddTextFrame($"Slide {i + 1}");
var n = slide.NotesSlideManager.AddNotesSlide();
n.NotesTextFrame.Text = noteTexts[i];
}
prs.Save("all-notes.pptx", SaveFormat.Pptx);Check Whether Notes Already Exist
NotesSlideManager.NotesSlide returns null if no notes slide has been created:
using Aspose.Slides.Foss;
using var prs = new Presentation("existing.pptx");
for (int i = 0; i < prs.Slides.Count; i++)
{
var existing = prs.Slides[i].NotesSlideManager.NotesSlide;
if (existing != null)
Console.WriteLine($"Slide {i + 1}: {existing.NotesTextFrame.Text[..60]}");
else
Console.WriteLine($"Slide {i + 1}: no notes");
}