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

Free Support Forum - aspose.com

Corrupt slide when cloned

I am trying to take 3 individual presentations (1 slide in each presentation) and combine them into 1 using the clone method. The result is a presentation file with what appears to be a few corrupt slides. The attached zip file includes the the 3 files, the template I add them to and an output file. Could someone tell me what the problem is? This same code will work fine on some presentations but not on others.

//Using Aspose.Slides v4.1.0

List<string> files = new List<string>();

files.Add(@"C:\PresentationBuilder\Copies\Example\Enhanced Cash Strategy Themes.ppt");

files.Add(@"C:\PresentationBuilder\Copies\Example\Equity Income Title Page.ppt");

files.Add(@"C:\PresentationBuilder\Copies\Example\Smid_Disclosure.ppt");

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

string copyFolder = "c:\\PresentationBuilder\\Copies\\";

if (!Directory.Exists(copyFolder))

Directory.CreateDirectory(copyFolder);

Aspose.Slides.Presentation template = new Aspose.Slides.Presentation("template.ppt");

foreach (string filePath in files)

{

Aspose.Slides.Presentation pres;

pres = new Aspose.Slides.Presentation(filePath);

pres.CloneSlide(pres.Slides[0], template.Slides.LastSlidePosition + 1, template, container);

}

template.Slides.Remove(template.Slides[0]);

template.Slides.Remove(template.Slides[0]);

template.Slides.Remove(template.Slides[0]);

string aDate = DateTime.Now.ToString("yyyyMMddhhmmss", CultureInfo.CreateSpecificCulture("en-US"));

string fileToSave = copyFolder + aDate + ".ppt";

template.Write(fileToSave);

Dear Michael,

Thanks for your interest in Aspose.Slides.

I have observed the code snippet shared by you and have observed little inconsistency in the code snippet. Actually, you need to add new instance of SortedList for each separate presentation. Please use the modified code snippet and hopefully, things will work for you.

foreach (string filePath in files)

{

container = new System.Collections.SortedList();

Aspose.Slides.Presentation pres;

pres = new Aspose.Slides.Presentation(filePath);

pres.CloneSlide(pres.Slides[0], template.Slides.LastSlidePosition + 1, template, container);

}

Thanks and Regards,

That was it!!! Thank you.