Free Support Forum - aspose.com

AddClone(srcSlide) includes Master

When I clone a slide from one presentation to another using AddClone(sourceSlide) it include the design/master of the source slide. How do I get around this or simply remove the design? I only want the content of the slide.

Thanks,
Christer

Hi Christer,

Thanks for considering Aspose.Slides.

When you are cloning a slide from some source presentation, the master slide for the cloned slide also gets copied. If you want only the source slide, then in that case you need to change the master of cloned slide with some slide of destination presentation and remove the old master slide from source presentation. Please use the following code snippet for changing slide master and removing older one.

Presentation Pres_Source = new Presentation("D://ppt//Test1.ppt");

Presentation Pres_Dest = new Presentation();

//Cloning Slide

System.Collections.SortedList sList = new System.Collections.SortedList();

Slide NewSlide=Pres_Source.CloneSlide(Pres_Source.Slides[0], 0, Pres_Dest, sList);

//Changing Master slide of cloned presentation

NewSlide.ChangeMaster(Pres_Dest.GetSlideById(d));

//Deleting unused old master of cloned slide

Pres_Dest.DeleteUnusedMasters();

Pres_Dest.Write("D://ppt//Test_Dest.ppt");

For your refernce, I have also attached the source presentation file.

Thanks and Regards,

My misstake, I ment using PPTX.

Hi Christer,

Please use the following code snippet for a changing the slide master of cloned slide.

PresentationEx Pres_Source = new PresentationEx("D://ppt//Test1.pptx");

PresentationEx Pres_Dest = new PresentationEx();

//Cloning Slides

SlidesEx Slides = Pres_Dest.Slides;

int SlideIndex=Slides.AddClone(Pres_Source.Slides[0]);

//Template slide

SlideEx Slide = Pres_Dest.Slides[0];

//Get the template master from template slide

MasterSlideEx masterslide = Slide.LayoutSlide.MasterSlide;

//Changing Slide master of cloned slide

Slide = Pres_Dest.Slides[(int)SlideIndex];

//Removing Old master

MasterSlideEx Oldmasterslide = Slide.LayoutSlide.MasterSlide;

Pres_Dest.Masters.Remove(Oldmasterslide);

Slide.LayoutSlide.MasterSlide = masterslide;

int c=Pres_Dest.Masters.Count;

//Saving presentation

Pres_Dest.Write("D://ppt//Test_Dest.pptx");

For reference, I have also attached the source presentation.

Thanks and Regards,