Clone Slide to Specified Position using Aspose.Slides

Aspose.Slides - Clone Slide to Specified Position

If you want to clone a slide and then use it within the same presentation file but at a different position, use the InsertClone method:

  1. Create an instance of the Presentation class.
  2. Instantiate the ISlideCollection class by referencing the Slides collection exposed by thePresentation object.
  3. Call the InsertClone method exposed by the ISlideCollection object and pass the slide to be cloned along with the index for the new position as a parameter to the InsertClonemethod.
  4. Write the modified presentation as a PPTX file.

Java

 //Instantiate Presentation class that represents a presentation file

Presentation pres = new Presentation(dataDir + "presentation.pptx");

//Clone the desired slide to the end of the collection of slides in the same presentation

ISlideCollection slds = pres.getSlides();

//Clone the desired slide to the specified index in the same presentation

slds.insertClone(2, pres.getSlides().get_Item(1));

Download Running Code

Download Sample Code