原創|使用教程|編輯:張瑩心|2021-11-04 11:36:58.947|閱讀 360 次
概述:您可以在 PowerPoint 幻燈片中使用頁眉和頁腳部分來顯示附加信息,例如幻燈片編號、日期、作者等。您還可以在 C++ 應用程序中以編程方式操作這些部分。為此,本文將教您 如何使用 C++ 在 PowerPoint 演示文稿中添加頁眉和頁腳。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
您可以在 PowerPoint 幻燈片中使用頁眉和頁腳部分來顯示附加信息,例如幻燈片編號、日期、作者等。您還可以在 C++ 應用程序中以編程方式操作這些部分。為此,本文將教您 如何使用 C++ 在 PowerPoint 演示文稿中添加頁眉和頁腳。
>>你可以點擊這里下載Aspose.Slides 最新版測試體驗。
// File paths const String sourceFilePath = u"SourceDirectory\\Slides\\Presentation2.pptx"; const String outputFilePath = u"OutputDirectory\\AddHeaderFooter_out.pptx"; // Load the Presentation file SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath); // Setting Footer presentation->get_HeaderFooterManager()->SetAllFootersText(u"My Footer text"); presentation->get_HeaderFooterManager()->SetAllFootersVisibility(true); // Access and Update Header auto masterNotesSlide = presentation->get_MasterNotesSlideManager()->get_MasterNotesSlide(); if (nullptr != masterNotesSlide) { for (const auto& shape : System::IterateOver(masterNotesSlide->get_Shapes())) { if (shape->get_Placeholder() != nullptr) { if (shape->get_Placeholder()->get_Type() == PlaceholderType::Header) { (System::DynamicCast<IAutoShape>(shape))->get_TextFrame()->set_Text(u"HI there new header"); } } } } // Save Presentation presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
// File paths const String sourceFilePath = u"OutputDirectory\\AddHeaderFooter_out.pptx"; const String outputFilePath = u"OutputDirectory\\ChangeHeaderFooterNotesMaster_out.pptx"; // Load the Presentation file SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath); // Change Header and Footer settings for notes master and all notes slides auto masterNotesSlide = presentation->get_MasterNotesSlideManager()->get_MasterNotesSlide(); if (masterNotesSlide != nullptr) { auto headerFooterManager = masterNotesSlide->get_HeaderFooterManager(); // Make the master notes slide and all child Footer placeholders visible headerFooterManager->SetHeaderAndChildHeadersVisibility(true); // Make the master notes slide and all child Header placeholders visible headerFooterManager->SetFooterAndChildFootersVisibility(true); // Make the master notes slide and all child SlideNumber placeholders visible headerFooterManager->SetSlideNumberAndChildSlideNumbersVisibility(true); // Make the master notes slide and all child Date and time placeholders visible headerFooterManager->SetDateTimeAndChildDateTimesVisibility(true); // Set text to master notes slide and all child Header placeholders headerFooterManager->SetHeaderAndChildHeadersText(u"Header text"); // Set text to master notes slide and all child Footer placeholders headerFooterManager->SetFooterAndChildFootersText(u"Footer text"); // Set text to master notes slide and all child Date and time placeholders headerFooterManager->SetDateTimeAndChildDateTimesText(u"Date and time text"); } // Save Presentation presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
// File paths const String sourceFilePath = u"OutputDirectory\\ChangeHeaderFooterNotesMaster_out.pptx"; const String outputFilePath = u"OutputDirectory\\ChangeHeaderFooterNotesSlide_out.pptx"; // Load the Presentation file SharedPtr<Presentation> presentation = MakeObject<Presentation>(sourceFilePath); // Change Header and Footer settings for first notes slide only auto notesSlide = presentation->get_Slides()->idx_get(0)->get_NotesSlideManager()->get_NotesSlide(); if (notesSlide != nullptr) { auto headerFooterManager = notesSlide->get_HeaderFooterManager(); if (!headerFooterManager->get_IsHeaderVisible()) { // Make this notes slide Header placeholder visible headerFooterManager->SetHeaderVisibility(true); } if (!headerFooterManager->get_IsFooterVisible()) { // Make this notes slide Footer placeholder visible headerFooterManager->SetFooterVisibility(true); } if (!headerFooterManager->get_IsSlideNumberVisible()) { // Make this notes slide SlideNumber placeholder visible headerFooterManager->SetSlideNumberVisibility(true); } if (!headerFooterManager->get_IsDateTimeVisible()) { // Make this notes slide Date-time placeholder visible headerFooterManager->SetDateTimeVisibility(true); } // Set text to notes slide Header placeholder headerFooterManager->SetHeaderText(u"New header text"); // Set text to notes slide Footer placeholder headerFooterManager->SetFooterText(u"New footer text"); // Set text to notes slide Date-time placeholder headerFooterManager->SetDateTimeText(u"New date and time text"); } // Save Presentation presentation->Save(outputFilePath, Aspose::Slides::Export::SaveFormat::Pptx);
如果你想試用Aspose的全部完整功能,可聯系在線客服獲取30天臨時授權體驗。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn