Created
August 17, 2020 11:47
-
-
Save aspose-com-gists/02b8b90a3b1b53e565530346be710916 to your computer and use it in GitHub Desktop.
Merge 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
// Instantiate a Presentation object that represents a target presentation file | |
using (Presentation presentation1 = new Presentation("presentation1.pptx")) | |
{ | |
// Instantiate a Presentation object that represents a source presentation file | |
using (Presentation presentation2 = new Presentation("presentation2.pptx")) | |
{ | |
// Merge only even slides of presentation2 (first slide is at 0 index) | |
for (int i = 1; i <= presentation2.Slides.Count; i = i + 2) | |
{ | |
presentation1.Slides.AddClone(presentation2.Slides[i]); | |
} | |
} | |
presentation1.Save("merged-presentation-even.pptx", 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
// Instantiate a Presentation object that represents a target presentation file | |
using (Presentation presentation1 = new Presentation("presentation1.pptx")) | |
{ | |
// Instantiate a Presentation object that represents a source presentation file | |
using (Presentation presentation2 = new Presentation("presentation2.pptx")) | |
{ | |
// Merge first two slides only using slide master | |
presentation1.Slides.AddClone(presentation2.Slides[0], presentation1.Masters[0], true); | |
presentation1.Slides.AddClone(presentation2.Slides[1], presentation1.Masters[0], true); | |
} | |
presentation1.Save("merged-presentation-master.pptx", 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
// Instantiate a Presentation object that represents a target presentation file | |
using (Presentation presentation1 = new Presentation("presentation1.pptx")) | |
{ | |
// Instantiate a Presentation object that represents a source presentation file | |
using (Presentation presentation2 = new Presentation("presentation2.pptx")) | |
{ | |
foreach (ISlide slide in presentation2.Slides) | |
{ | |
// Merge slides from source to target | |
presentation1.Slides.AddClone(slide); | |
} | |
} | |
// Save the presentation | |
presentation1.Save("merged-presentation.pptx", Export.SaveFormat.Pptx); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment