You can find detailed information at: Access or Modify Properties of PowerPoint Files using C++
Last active
October 22, 2021 10:00
-
-
Save aspose-com-gists/e41095433eb735742b5dfdf2f202561d to your computer and use it in GitHub Desktop.
Access or Modify Properties of PowerPoint Files using C++
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File paths | |
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx"; | |
const String outputFilePath = u"OutputDirectory\\AccessAndModifyCustomProperties_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Create a reference to DocumentProperties object associated with Presentation | |
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties(); | |
// Access custom properties | |
for (int32_t i = 0; i < documentProperties->get_CountOfCustomProperties(); i++) | |
{ | |
// Print the name and value of custom properties | |
System::Console::WriteLine(u"Custom Property Name : {0}", documentProperties->GetCustomPropertyName(i)); | |
System::Console::WriteLine(u"Custom Property Value : {0}", documentProperties->idx_get(documentProperties->GetCustomPropertyName(i))); | |
// Modify the custom property | |
documentProperties->SetCustomPropertyValue(documentProperties->GetCustomPropertyName(i), String::Format(u"Title : {0}", i)); | |
} | |
// Save Presentation | |
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File path | |
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Get reference of document properties | |
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties(); | |
// Print the property values | |
System::Console::WriteLine(u"Category : {0}", documentProperties->get_Category()); | |
System::Console::WriteLine(u"Current Status : {0}", documentProperties->get_ContentStatus()); | |
System::Console::WriteLine(u"Creation Date : {0}", documentProperties->get_CreatedTime().ToString()); | |
System::Console::WriteLine(u"Author : {0}", documentProperties->get_Author()); | |
System::Console::WriteLine(u"Description : {0}", documentProperties->get_Comments()); | |
System::Console::WriteLine(u"KeyWords : {0}", documentProperties->get_Keywords()); | |
System::Console::WriteLine(u"Last Modified By : {0}", documentProperties->get_LastSavedBy()); | |
System::Console::WriteLine(u"Supervisor : {0}", documentProperties->get_Manager()); | |
System::Console::WriteLine(u"Modified Date : {0}", documentProperties->get_LastSavedTime().ToString()); | |
System::Console::WriteLine(u"Presentation Format : {0}", documentProperties->get_PresentationFormat()); | |
System::Console::WriteLine(u"Last Print Date : {0}", documentProperties->get_LastPrinted().ToString()); | |
System::Console::WriteLine(u"Is Shared between producers : {0}", documentProperties->get_SharedDoc()); | |
System::Console::WriteLine(u"Subject : {0}", documentProperties->get_Subject()); | |
System::Console::WriteLine(u"Title : {0}", documentProperties->get_Title()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File paths | |
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx"; | |
const String outputFilePath = u"OutputDirectory\\AddCustomProperties_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Get reference of document properties | |
auto documentProperties = presentation->get_DocumentProperties(); | |
// Adding Custom properties | |
documentProperties->idx_set(u"New Custom", ObjectExt::Box<int32_t>(12)); | |
documentProperties->idx_set(u"My Name", ObjectExt::Box<String>(u"Aspose")); | |
documentProperties->idx_set(u"Custom", ObjectExt::Box<int32_t>(124)); | |
// Getting property name at particular index | |
String getPropertyName = documentProperties->GetCustomPropertyName(2); | |
// Removing selected property | |
documentProperties->RemoveCustomProperty(getPropertyName); | |
// Save Presentation | |
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File paths | |
const String sourceFilePath = u"SourceDirectory\\Slides\\SamplePresentation.pptx"; | |
const String outputFilePath = u"OutputDirectory\\ModifyBuiltinProperties_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Get reference of document properties | |
System::SharedPtr<IDocumentProperties> documentProperties = presentation->get_DocumentProperties(); | |
// Modify the built-in properties | |
documentProperties->set_Author(u"Aspose.Slides for C++"); | |
documentProperties->set_Title(u"Modifying Presentation Properties"); | |
documentProperties->set_Subject(u"Aspose Subject"); | |
documentProperties->set_Comments(u"Aspose Comments"); | |
documentProperties->set_Manager(u"Aspose Manager"); | |
// Save Presentation | |
presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment