Mange PowerPoint Slide Notes

Microsoft PowerPoint provides you with the option to add notes to your slides. These notes can be helpful for the presenter by providing additional information and context. You might find yourself in situations where you have to add or update such notes programmatically in your PowerPoint presentations. In light of that, this article will teach you how to work with notes in PowerPoint presentations programmatically using C++.

C++ API for Working with Notes in PowerPoint Presentations

Aspose.Slides for C++ is a native C++ library that supports creating, reading, and manipulating PowerPoint files. The API also supports working with notes in PowerPoint presentations. You can either install the API through NuGet or download it directly from the Downloads section.

PM> Install-Package Aspose.Slides.Cpp

Read Notes from a PowerPoint Slide using C++

The following are the steps to read notes from a PowerPoint Slide.

The following is the sample code to read notes from a PowerPoint slide using C++.

// Source PowerPoint file
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Read slide notes
SharedPtr<INotesSlide> note = notesManager->get_NotesSlide();
Console::WriteLine(note->get_NotesTextFrame()->get_Text());

Add Notes to a PowerPoint Slide using C++

Aspose.Slides for C++ provides you with the ability to add notes to PowerPoint slides. For that, access the INotesSlideManager for the required slide and then add the note. The following are the steps to add notes to a specific PowerPoint slide.

The following is the sample code to add notes to a specific PowerPoint slide using C++.

// File paths
const String sourceFilePath = u"SourceDirectory\\SamplePresentation.pptx";
const String outputFilePath = u"OutputDirectory\\added-slide-notes.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Add new slide notes
SharedPtr<INotesSlide> note = notesManager->AddNotesSlide();
// Set the note text
note->get_NotesTextFrame()->set_Text(u"Test");
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

Update Notes of PowerPoint Slides using C++

To update the notes, you retrieve the existing note with the INotesSlideManager and then update the note text. The following are the steps to update the notes of a PowerPoint slide.

The following is the sample code to update the notes of a PowerPoint slide using C++.

// File paths
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\updated-slide-notes.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Access slide notes
SharedPtr<INotesSlide> note = notesManager->get_NotesSlide();
// Update the notes
note->get_NotesTextFrame()->set_Text(u"Test Updated");
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

Remove Notes from a PowerPoint Slide using C++

Remove the notes from a slide by retrieving the INotesSlideManager for that particular slide and then using the RemoveNotesSlide() method. The following are the steps to remove notes from a PowerPoint slide.

The following is the sample code to remove notes from a PowerPoint slide using C++.

// File paths
const String sourceFilePath = u"SourceDirectory\\slide-notes.pptx";
const String outputFilePath = u"OutputDirectory\\removed-slide-notes.pptx";
// Load the Presentation file
SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath);
SharedPtr<INotesSlideManager> notesManager = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager();
// Remove slide notes
notesManager->RemoveNotesSlide();
// Save Presentation file
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);

Get a Free License

You can request a free temporary license to try the API without evaluation limitations.

Conclusion

In this article, you have learned how to manage slide notes in PowerPoint presentations using C++. Specifically, you have learned how to read, add, update and remove notes from PowerPoint slides. Aspose.Slides for C++ also provides many additional features that aid you in your presentation-related tasks. You can explore the API in detail by visiting the official documentation. In case of any questions, please feel free to reach us on our free support forum.

See Also