How to update an existing image with new image in Aspose Slides

Hi,

Thanks for quick reply ..

In my project i am using Version 7.6.0.0 ... I want code in PresentationEX..

IN ShapeEx "shp.FillFormat.PictureId;" Is not there. Could you please send equilent code for below requirement.

Thanks.

Sudheer k

HI ,

Could you please tell me that , How can we access a image in a PPT slide and update image programatically .. My requirement is in Template slide i will place a image with some width and height and then i want to update existing image with new image programatically at run time (C#).

(Like accessing existing charts and tables i want to access image also to change image).

Please let me know if there is any way to accomplish this task.

Thanks,

Sudheer K

Hi Sudheer K,

I have observed the requirement shared by you and suggest you to please try using following sample code on your end to serve the purpose. Please share, if I may help you further in this regard.

public static void ChangePPTImage()
{
String path = @“D:\Aspose Data”;

//Accessing the presentation
Presentation pres = new Presentation(path + “demo.ppt”);

Slide sl;
for (int i = 1; i <= pres.Slides.LastSlidePosition; i++)
{
sl = pres.GetSlideByPosition(i);

for (int j = 0; j < sl.Shapes.Count; j++)
{

// Accessing the shape with picture
Aspose.Slides.Shape sh = sl.Shapes[j];

//Getting the fill type of the shape
FillType fillType = sh.FillFormat.Type;

int PicFormat = 0;
int Id = 0;

//If the fill type of shape is picture
if (fillType == FillType.Picture)
{
//Getting the picture ID
Id = sh.FillFormat.PictureId;
//Getting the picture format of the image in shape


Picture pic = new Picture(pres, @“C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg”);

//Adding the picture object to pictures collection of the presentation
//After the picture object is added, the picture is given a uniqe picture Id
int picId = pres.Pictures.Add(pic);

//Setting the picture Id of the shape fill to the Id of the picture object
sh.FillFormat.PictureId = picId;

}
}
}

pres.Write(path + “ChangedPic.ppt”);
}
Many Thanks,