We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem with many masters when cloning slides

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.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;

Dear Ken,

Thanks for considering Aspose.Slides.

Please remember that TreeMap parameter in Java is used by Aspose.Slides internally and contains shapes identifiers and should be unique for each source-target presentations pair. So, if you clone several slides from one source presentation to one target presentation and use the same TreeMap for that then only one master slide will be copied for all cloned slides. If you use unique TreeMap for each clone operation then new copy of master slide will be copied for each cloned slide. So, using single TreeMap for one source will reduce the number of master slides. For further details and reference please follow the code snippet provided on this link. The code snippet will help you cloning slides from different source presentations and applying the destination master on them and deleting the copied one.

Please feel free to share, if you have any other queries.

Thanks and Regards,