You can use header and footer sections in PowerPoint slides to display additional information such as slide number, date, author, etc. You can also manipulate these sections programmatically within your C++ applications. To that end, this article will teach you how to add header and footer in PowerPoint presentations using C++.
- C++ API for Adding Header and Footer in PowerPoint Presentations
- Add Header and Footer in PowerPoint Presentations using C++
- Manage Header and Footer in Notes Master and Notes Slides using C++
C++ API for Adding Header and Footer in PowerPoint Presentations
We will use the Aspose.Slides for C++ API to add header and footer in PowerPoint presentations. It is a robust API providing many features for working with PowerPoint PPTX/PPT files. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Add Header and Footer in PowerPoint Presentations using C++
The following are the steps for adding header and footer in PowerPoint presentations.
- Firstly, load the PowerPoint file using the Presentation class.
- Set the footer text using the Presentation->get_HeaderFooterManager()->SetAllFootersText(System::String text) method.
- Show the footer by setting its visibility using the Presentation->get_HeaderFooterManager()->SetAllFootersVisibility(bool isVisible) method.
- Access the master notes slide using the Presentation->get_MasterNotesSlideManager()->get_MasterNotesSlide() method.
- Loop through the shapes of the master notes slide.
- If the shape is of the type PlaceholderType::Header, set the header text using the IAutoShape->get_TextFrame()->set_Text(System::String value) method.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to add a header and footer in a PowerPoint presentation using C++.
Manage Header and Footer in Notes Master and Notes Slides using C++
With Aspose.Slides for C++, you can easily manage header and footer for both notes master and notes slides. The following sections cover how to manage header and footer in notes master and notes slides.
Change Header and Footer Settings for Notes Master
The following are the steps to change the header and footer settings for notes master.
- Firstly, load the PowerPoint file using the Presentation class.
- Access the master notes slide using the Presentation->get_MasterNotesSlideManager()->get_MasterNotesSlide() method.
- Access the IMasterNotesSlideHeaderFooterManager using the IMasterNotesSlide->get_HeaderFooterManager() method.
- Use the IMasterNotesSlideHeaderFooterManager object to update the header and footer.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to change the header and footer in notes master using C++.
Change Header and Footer Settings for Notes Slide
The following are the steps to change the header and footer settings for notes slides.
- Firstly, load the PowerPoint file using the Presentation class.
- Access the notes slide using the Presentation->get_Slides()->idx_get(0)->get_NotesSlideManager()->get_NotesSlide() method.
- Access the INotesSlideHeaderFooterManager using the INotesSlide->get_HeaderFooterManager() method.
- Use the INotesSlideHeaderFooterManager object to update the header and footer.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to change the header and footer in the notes slide using C++.
Get a Free License
In order to try the API without evaluation limitations, you can request a free temporary license.
Conclusion
In this article, you have learned how to add header and footer in PowerPoint presentations using C++. Furthermore, you have seen how to change the header and footer in notes master and notes slide using Aspose.Slides for C++ API. It is a powerful API that provides a bunch of additional features for working with PowerPoint PPTX/PPT files. You can explore the API in detail by visiting the official documentation. In case of any queries, please feel free to reach us at our free support forum.