原創|使用教程|編輯:張瑩心|2021-11-01 10:00:01.647|閱讀 221 次
概述:PowerPoint 文件包含提供有關演示文稿的附加信息的元數據或文檔屬性。其中包括演示文稿的標題、日期、作者等信息。在本文中,將學習 如何使用 C++ 訪問和修改 PowerPoint 演示文稿中的屬性。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
PowerPoint 文件包含提供有關演示文稿的附加信息的元數據或文檔屬性。其中包括演示文稿的標題、日期、作者等信息。在本文中,將學習 如何使用 C++ 訪問和修改 PowerPoint 演示文稿中的屬性。
>>你可以點擊這里下載Aspose.Slides 最新版測試體驗。
// 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());
// 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);
// 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);
// 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);
如果你想試用Aspose的全部完整功能,可聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn