While I am replacing pictures with another picture in a slide, the animation associated with the pictures are getting lost.
string output_file_name = string.Empty;
string[] files = System.IO.Directory.GetFiles(fPPTPath);
string fileName = string.Empty;
String PPTFullPath = fPPTPath + “\” + pptname;
Presentation presnew = new Presentation(PPTFullPath);
try
{
Workbook wb = new Workbook();
wb.Open(Excelfile);
wb.CalculateFormula();
XmlDocument xDoc = new XmlDocument();
ArrayList arImage = new ArrayList();
xDoc.Load(fMappingXMLPath);
XmlNodeList xmlimage = xDoc.GetElementsByTagName(“image”);
XmlNodeList xmlImgName = xDoc.GetElementsByTagName(“name”);
int imagecount = 0;
//Read from chartlist.xml file and store images name in Array object
foreach (XmlElement NewImg in xmlImgName)
{
arImage.Add(NewImg.InnerText);
imagecount++;
}
for (int j = 1; j <= presnew.Slides.Count; j++)
{
Slide slide = presnew.GetSlideByPosition(j);
Aspose.Slides.Shapes shapes = slide.Shapes;
for (int i = 0; i < shapes.Count; i++)
{
Aspose.Slides.Shape shape = shapes[i];
//check if the shape is Picture
if (shape is PictureFrame)
{
PictureFrame pic = shape as PictureFrame;
if (pic.AlternativeText == “CustomerName”)
{
}
else if (pic.AlternativeText != “”)
{
for (int k = 0; k < imagecount; k++)
{
string newpic_name = arImage[k].ToString();
//match d alternate text on image wid d image name read from xml file
if (pic.AlternativeText != null && pic.AlternativeText != “” && pic.AlternativeText == newpic_name)
{
//get d absolute path of newpic
string str = fPPTPath + “\” + arImage[k].ToString() + “.jpeg”;
Aspose.Slides.Picture new_pic = new Aspose.Slides.Picture(slide.Parent, str);
int old_pic_id = pic.PictureId,
new_pic_id = slide.Parent.Pictures.Add(new_pic);
pic.PictureId = new_pic_id;
break;
}
}
}
}
}
}
//Save the modified PPT as Output.ppt
output_file_name = fPPTPath + “\” + pptname;
presnew.Write(output_file_name);