You can find detailed information at: Set Slide Background in PowerPoint Presentations using C++
Last active
October 12, 2021 17:16
-
-
Save aspose-com-gists/c98bfe5138c04e8695bbccd09229edd8 to your computer and use it in GitHub Desktop.
Set Slide Background in PowerPoint Presentations 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\\Presentation2.pptx"; | |
const String outputFilePath = u"OutputDirectory\\SetMasterSlideBackground_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Set the background color of the Master ISlide to Forest Green | |
presentation->get_Masters()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground); | |
presentation->get_Masters()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Solid); | |
presentation->get_Masters()->idx_get(0)->get_Background()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_ForestGreen()); | |
// 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\\Presentation2.pptx"; | |
const String outputFilePath = u"OutputDirectory\\SetSlideBackground_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Set the background color of the first ISlide to Blue | |
presentation->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Solid); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_SolidFillColor()->set_Color(System::Drawing::Color::get_Blue()); | |
// 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\\Presentation2.pptx"; | |
const String outputFilePath = u"OutputDirectory\\SetSlideGradientBackground_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Apply Gradient effect to the Background | |
presentation->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Gradient); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_GradientFormat()->set_TileFlip(TileFlip::FlipBoth); | |
// 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\\Presentation2.pptx"; | |
const String imageFilePath = u"SourceDirectory\\Images\\Tulips.jpg"; | |
const String outputFilePath = u"OutputDirectory\\SetSlideImageBackground_out.pptx"; | |
// Load the presentation file | |
auto presentation = System::MakeObject<Presentation>(sourceFilePath); | |
// Set background properties | |
presentation->get_Slides()->idx_get(0)->get_Background()->set_Type(BackgroundType::OwnBackground); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->set_FillType(FillType::Picture); | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_PictureFillFormat()->set_PictureFillMode(PictureFillMode::Stretch); | |
// Get the picture | |
auto bitmap = MakeObject<System::Drawing::Bitmap>(imageFilePath); | |
// Add image to presentation's images collection | |
SharedPtr<IPPImage> imgx = presentation->get_Images()->AddImage(bitmap); | |
// Set the image as the background | |
presentation->get_Slides()->idx_get(0)->get_Background()->get_FillFormat()->get_PictureFillFormat()->get_Picture()->set_Image(imgx); | |
// 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