I'm using GemBox.Presentation and I need to merge multiple PPTX files, combine them into a single PPTX file.
I tried this:
PresentationDocument presentation1 = PresentationDocument.Load("PowerPoint1.pptx");
PresentationDocument presentation2 = PresentationDocument.Load("PowerPoint2.pptx");
foreach (Slide slide2 in presentation2.Slides)
presentation1.Slides.Add(slide2);
But I get the following error:
Item is already contained in some collection. Remove it from that collection first.
Parameter name: item
How can I merge several presentations into one presentation?
Use one of the
AddCopy
methods instead ofAdd
.In other words, try this:
Also, you can refer to Cloning example.