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

Free Support Forum - aspose.com

How to add 8 slides in a presentation using Aspose slide version 14.6.0.0

Hi,

I want to create a PPTX file same as shown in attached image.

Do i need to use insertclone method for this....

slds.InsertClone(2, pres.Slides[1]);

Thanks,

Praveen

Hi Praveen,

I have observed your requirement for copying slides in your presentation. The code sample shared by you seems OK. Please visit this documentation link for detailed article on slides cloning. Please share, if I may help you further in this regard.

Many Thanks,

Hi,

When i use the above code i get the error. please let me know When i use the above code i get the error. please let me know

  • //Instantiate Presentation class that represents a presentation file using(Presentation pres = new Presentation("helloworld.pptx"))
    {

    //Clone the desired slide to the end of the collection of slides in the same presentation ISlideCollection slds = pres.Slides;

    //Clone the desired slide to the specified index in the same presentation slds.InsertClone(2, pres.Slides[1]);

    //Write the modified presentation to disk pres.Save("helloworld_clonedPost.pptx", SaveFormat.Pptx);

    }//Instantiate Presentation class that represents a presentation file using(Presentation pres = new Presentation("helloworld.pptx"))
    {

    //Clone the desired slide to the end of the collection of slides in the same presentation ISlideCollection slds = pres.Slides;

    //Clone the desired slide to the specified index in the same presentation slds.InsertClone(2, pres.Slides[1]);

    //Write the modified presentation to disk pres.Save("helloworld_clonedPost.pptx", SaveFormat.Pptx);

    }

Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index

Thanks,

Praveen

Hi Praveen,

I have observed the sample code shared. It seems that the index on which you are trying to clone slide does not exist in slide. Like you have only 1 slide in presnetation that you want to clone. Its index will be 0. So, next slide when you clone by using InsertClone has to be less than or equal to Total Slide In Presentation - 1. In your case you are cloning on index that is probably greater than total slides - 1.Please try using the following sample code on your end. In your

public static void testClone()
{
Presentation pres = new Presentation(“helloworld.pptx”);
ISlideCollection slides = pres.Slides;
//First slide in collection
ISlide slideToClone= slides[0];

//Clone slide 8 times
for (int i = 0; i < 8; i++)
{
//Clone slide at end of collection
slides.AddClone(slideToClone);

//OR
//Clone slide at end of Collection
slides.InsertClone((pres.Slides.Count-1),slideToClone);
}

//Write the modified presentation to disk
pres.Save(“helloworld_clonedPost.pptx”, SaveFormat.Pptx);

}

Many Thanks,

Hi,

I want to generate a PPTX file as same as attached one.

Can you please send me the code.

Thanks,

Praveen

Hi Praveen,

Thank you for the sample file.

We will check it and get back to you with the sample code.

Thanks & Regards,