PowerPoint files contain metadata or document properties that provide additional information about the presentation. These include information such as the title, date, author, etc., of the presentation. In this article, you will learn how to read or edit document properties in PowerPoint files in C++.
- PowerPoint Document Properties - API Installation
- Types of Properties in PowerPoint Presentations
- Access Document Properties in PowerPoint in C++
- Change Document Properties in PowerPoint Presentations
- Add Custom Properties in PowerPoint Presentations
- Access and Modify Custom Properties in PowerPoint Presentations
- Change File Properties Online
PowerPoint Document Properties - API Installation
Aspose.Slides for C++ is a C++ API for working with PowerPoint files. It enables you to create, read and update PowerPoint files without needing additional software. Furthermore, the API allows you to access and modify the properties of PowerPoint presentations. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Slides.Cpp
Types of Properties in PowerPoint Presentations
There are two types of properties in PowerPoint presentations: built-in and custom. The built-in properties store general information about the presentations like the title, date, etc. On the other hand, custom properties store custom information in key/value pairs. The following sections cover how to add, access, and modify built-in and custom properties of PowerPoint presentations.
Access Document Properties in PowerPoint in C++
The following are the steps to access built-in properties in PowerPoint presentations.
- Firstly, load the PowerPoint file using the Presentation class.
- Access the properties using the Presentation->get_DocumentProperties() method.
- Read the individual properties using the IDocumentProperties object with methods like IDocumentProperties->get_Category(), IDocumentProperties->get_Author(), etc.
The following sample code shows how to access built-in properties in PowerPoint presentations using C++.
Change Document Properties in PowerPoint Presentations using C++
The following are the steps to modify built-in properties in PowerPoint presentations.
- Firstly, load the PowerPoint file using the Presentation class.
- Retrieve the properties in the IDocumentProperties object using the Presentation->get_DocumentProperties() method.
- Modify the properties using the IDocumentProperties object with methods like IDocumentProperties->set_Author(System::String value), IDocumentProperties->set_Title(System::String value), etc.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to modify built-in PowerPoint properties using C++.
Add Custom Properties in PowerPoint Presentations using C++
The following are the steps to add custom properties in PowerPoint presentations.
- Firstly, load the PowerPoint file using the Presentation class.
- Retrieve the properties in the IDocumentProperties object using the Presentation->get_DocumentProperties() method.
- Add the custom properties using the IDocumentProperties->idx_set(System::String name, System::SharedPtrSystem::Object 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 custom properties in PowerPoint presentations.
Access and Modify Custom Properties in PowerPoint Presentations
The following are the steps to access and modify PowerPoint document properties.
- Firstly, load the PowerPoint file using the Presentation class.
- Retrieve the properties in the IDocumentProperties object using the Presentation->get_DocumentProperties() method.
- Loop through the properties and access each property’s name and value using the IDocumentProperties->GetCustomPropertyName(int32_t index) and IDocumentProperties->idx_get(System::String name) methods respectively.
- Modify the required custom properties using the IDocumentProperties->SetCustomPropertyValue() method based on the type of the value you want to store.
- Finally, save the presentation using the Presentation->Save(System::String fname, Export::SaveFormat format) method.
The following sample code shows how to access and modify custom properties in PowerPoint presentations using C++.
Change File Properties Online
We highly recommend you use our online tool to change file properties online. It is free and you can use it in any popular web browser.
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 read or edit document properties in PowerPoint files in C++. Furthermore, you have seen how to add, access, and modify custom PowerPoint properties using Aspose.Slides for C++ API. It is a robust API with lots of additional features for automating your PowerPoint-related tasks. 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.