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

Free Support Forum - aspose.com

Problem with CloneSlide function

I’m trying to merge multiple PPT files to one file.
So I’m using CloneSlide function.
The PPT file has Table and Images. When I clone PPT file, Table and text is OK. But Image file has broken.

Here is code. Also I attached sample PPT files.

private void MergePPTFiles()
{
// int lcShapeCounter_int = 0;
string lcReportIndex_str = string.Empty;
string lcTemplateFolder = string.Empty;
string lcTargetFolder = string.Empty;

lcTemplateFolder = Server.MapPath("~/Template");
lcTargetFolder = Server.MapPath("~/TempPPT");

int count = sReportList.Items.Count;

License AsposeLic = new License();
AsposeLic.SetLicense(Server.MapPath("~/bin") + “\Aspose.Slides.lic”);

Aspose.Slides.Presentation newPres = new Presentation(@lcTemplateFolder + “\Title.ppt”);

for (int j = 0; j < count; j++)
{
string lcReportName_str = string.Empty;
string reportName = sReportList.Items[j].Text;

//create the index text for the first slide
lcReportIndex_str += reportName + “\r\n”;

Aspose.Slides.Presentation srcPres = new Aspose.Slides.Presentation(@lcTargetFolder + “\” + reportName.Replace(’ ', ‘_’) + “.ppt”);

for (int slides = 1 ; slides <= srcPres.Slides.Count; slides++) {
// ids.clear();
Aspose.Slides.Slide slide = srcPres.GetSlideByPosition(slides);

newPres.CloneSlide(slide, newPres.Slides.LastSlidePosition + 1);
}//end for
}
newPres.Write(@lcTargetFolder + “\Target.ppt”);
}

Dear Calvin,

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

When you are cloning a slide from another presentation, you should use the second overload of cloneslide method.

public Slide CloneSlide(
Slide srcSlide,
int position,
Presentation pres,
SortedList idList
);

So you should change your code like this.

srcPres.CloneSlide(slide, newPres.Slides.LastSlidePosition + 1, newPres, new SortedList());