Extract comments from presentation slides and save in txt file

Comments on the presentation slides given the additional information of a phrase or the whole paragraph. By using Spire.Presentation, developers can easily add new comments to the slide, edit and remove the special comment from the presentation slides. Also, the existing comments can be extracted from document and this article demonstrates how to extract comments from presentation slides and save to TXT file in C#.

Please view the presentation with comments that will be extracted later:

Extract comments from presentation slides and save in txt file

Step 1: Create a new presentation document and load from the file.

Presentation ppt = new Presentation();
ppt.LoadFromFile("Sample.pptx");

Step 2: Get all comments from the first slide.

StringBuilder str= new StringBuilder();

Comment[] comments = ppt.Slides[0].Comments;

for(int i=0; i < comments.Length;i++)
{
    str.Append(comments[i].Text + "\r\n");
}
String fileName = "TextFromComment.txt";

Step 3: Save to TXT file.

File.WriteAllText("TextFromComment.txt", str.ToString());

Effective screenshot after extracted all the comments from the first slide and save it in Txt file:

Extract comments from presentation slides and save in txt file

Full codes:

using Spire.Presentation;
using System.IO;
using System.Text;
namespace SpeakerNotes
{

    class Program
    {

        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("Sample.pptx");

            StringBuilder str = new StringBuilder();

            Comment[] comments = ppt.Slides[0].Comments;

            for (int i = 0; i < comments.Length; i++)
            {
                str.Append(comments[i].Text + "\r\n");
            }

            File.WriteAllText("TextFromComment.txt", str.ToString());

        }

    }
}