Last active
March 13, 2021 10:58
-
-
Save aspose-com-gists/3fbb5a14be693e49be410ae57cf50d56 to your computer and use it in GitHub Desktop.
Merge PowerPoint Slides 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
Merge PowerPoint Slides 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
// The path to the documents directory. | |
const String sourceFilePath1 = u"SourceDirectory\\SamplePresentation2.pptx"; | |
const String sourceFilePath2 = u"SourceDirectory\\SamplePresentation3.pptx"; | |
const String outputFilePath = u"OutputDirectory\\mergedPresentation.pptx"; | |
// Instantiate Presentation class | |
SharedPtr<Presentation> presentation1 = MakeObject<Presentation>(sourceFilePath1); | |
SharedPtr<Presentation> presentation2 = MakeObject<Presentation>(sourceFilePath2); | |
for (SharedPtr<ISlide> slide : presentation2->get_Slides()) | |
{ | |
// Merge slides from source to destination | |
presentation1->get_Slides()->AddClone(slide); | |
} | |
// Save the presentation | |
presentation1->Save(outputFilePath, 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
// The path to the documents directory. | |
const String sourceFilePath1 = u"SourceDirectory\\SamplePresentation.pptx"; | |
const String sourceFilePath2 = u"SourceDirectory\\SamplePresentation3.pptx"; | |
const String outputFilePath = u"OutputDirectory\\mergedPresentation.pptx"; | |
// Load the presentation files | |
SharedPtr<Presentation> presentation1 = MakeObject<Presentation>(sourceFilePath1); | |
SharedPtr<Presentation> presentation2 = MakeObject<Presentation>(sourceFilePath2); | |
// Merge the first slide using slide master | |
presentation1->get_Slides()->AddClone(presentation2->get_Slides()->idx_get(0), presentation1->get_Masters()->idx_get(0), true); | |
// Save the presentation | |
presentation1->Save(outputFilePath, 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
// The path to the documents directory. | |
const String sourceFilePath1 = u"SourceDirectory\\SamplePresentation2.pptx"; | |
const String sourceFilePath2 = u"SourceDirectory\\SamplePresentation3.pptx"; | |
const String outputFilePath = u"OutputDirectory\\mergedPresentation.pptx"; | |
// Load the presentation files | |
SharedPtr<Presentation> presentation1 = MakeObject<Presentation>(sourceFilePath1); | |
SharedPtr<Presentation> presentation2 = MakeObject<Presentation>(sourceFilePath2); | |
for (int i = 0; i < presentation2->get_Slides()->get_Count(); i++) | |
{ | |
// Merge only even slides | |
if (i % 2 == 0) | |
{ | |
presentation1->get_Slides()->AddClone(presentation2->get_Slides()->idx_get(i)); | |
} | |
} | |
// Save the presentation | |
presentation1->Save(outputFilePath, SaveFormat::Pptx); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment