I'm developing an application which creates a final presentation by copying (cloning) slides from several presentations. After even cloning from one presentation I'm ending up with lots of masters.
My code is as follows:
// NOTE: outputPresentation is my new (output) presentation; the open code looks like:
outputPresentation = new Presentation(EmiStandardFunctions.getConfig("path") + "documents\\template.ppt");
and sList is declared in my class as:
private System.Collections.SortedList sList = new System.Collections.SortedList();
After copying my wrapup code is:
outputPresentation.DeleteUnusedMasters();
outputPresentation.Save(EmiStandardFunctions.getConfig("path") + "temporary_directory\\" + tempFileName + ".ppt", Aspose.Slides.Export.SaveFormat.Ppt );
The copy code is:
private void appendPresentationToOutput(string docName)
{
Presentation inPresentation;
string pptNameFullPath;
Slide fromSlide;
uint mainMaster;
pptNameFullPath = EmiStandardFunctions.getConfig("path") + "documents\\" + docName; // this is the presentation I'm copying FROM
inPresentation = new Presentation(pptNameFullPath);
mainMaster = outputPresentation.GetSlideByPosition(1).MasterId; // this is the master slide I want to use
for (int slideNo = 1; slideNo <= inPresentation.Slides.Count; slideNo++)
{
fromSlide = inPresentation.GetSlideByPosition(slideNo);
inPresentation.CloneSlide(fromSlide, outputPresentation.Slides.LastSlidePosition + 1, outputPresentation, sList);
outputPresentation.GetSlideByPosition(outputPresentation.Slides.LastSlidePosition).ChangeMaster(outputPresentation.GetSlideById(mainMaster), false);
fromSlide = null;
}
inPresentation = null;
}