How to Add Comments to PowerPoint in .NET

How to Add Comments to PowerPoint in .NET

This guide shows how to add comments and speaker notes to PowerPoint slides using Aspose.Slides FOSS for .NET. Use prs.CommentAuthors.AddAuthor() to create a comment author, then call author.Comments.AddComment() to attach threaded comments to a slide at a specific position. Use slide.NotesSlideManager.AddNotesSlide() to add per-slide speaker notes visible in Presenter View.


Prerequisites

Add the following package reference to your project by running the dotnet CLI install command:

dotnet add package Aspose.Slides.Foss

Add 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

Create multiple authors by calling prs.CommentAuthors.AddAuthor() once per author, then post comments from each author independently:

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

Load an existing file with new Presentation(path) and iterate over prs.CommentAuthors to read each author’s comments:

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

Create a notes slide by calling slide.NotesSlideManager.AddNotesSlide() and write the presenter text to notes.NotesTextFrame.Text:

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

To add speaker notes to every slide in a batch, iterate over prs.Slides and call NotesSlideManager.AddNotesSlide() on each slide:

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");
}

See Also

 English