AddClone(srcSlide) includes Master

Last post 04-28-2010, 8:22 AM by Mudassir. 3 replies.
Sort Posts: Previous Next
  •  04-27-2010, 4:41 PM 234958

    AddClone(srcSlide) includes Master .NET

    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

    Filed under: addClone
     
  •  04-28-2010, 1:19 AM 235016 in reply to 234958

    Re: AddClone(srcSlide) includes Master

    Attachment: Present (inaccessible)

    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, 


    Mudassir Fayyaz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
  •  04-28-2010, 2:55 AM 235045 in reply to 235016

    Re: AddClone(srcSlide) includes Master .NET

    My misstake, I ment using PPTX.
     
  •  04-28-2010, 8:22 AM 235108 in reply to 235045

    Re: AddClone(srcSlide) includes Master

    Attachment: Present (inaccessible)

    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,


    Mudassir Fayyaz
    Support Developer
    Aspose Sialkot Team
    Contact Us
    Aspose - The .NET and Java Component Publisher

    Keep in touch! We're on Twitter and Facebook
     
View as RSS news feed in XML