1) Please show samples to add 4 images to avoid message “Object Changed” and ole frames on different part of the ppt slide. In between these images would be a place to add ppt slide content.
Hi,
Thanks for considering Asopose.Slides.
In view of our discussion regarding addition of multiple picture frames in PPT slide, I have formulated a code snippet for you. Please use the code snippet given below.
//Instantiate a Presentation object that represents a PPT file
Presentation pres = new Presentation();
//Accessing a slide using its slide position
Slide slide = pres.AddBodySlide();
int c = slide.Shapes.Count;
//Calculating slide width and height
//Accessing the first placeholder in the slide and typecasting it as a text holder
TextHolder th = (TextHolder)slide.Placeholders[1];
th.Text="ASPOSE";
int slideWidth = slide.Background.Width;
int slideHeight = slide.Background.Height;
Shape Shp = slide.Shapes[1];
Shp.X=slideWidth / 4;
Shp.Y = slideHeight / 4;
String sPath = @"D\ppt\";
String sPicPath = @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\";
//Creating a picture object that will be used to fill the ellipse
Picture pic = new Picture(pres, sPicPath+"Blue hills.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);
//Calculating picture width and height
int pictureWidth = pres.Pictures[picId - 1].Image.Width * 2;
int pictureHeight = pres.Pictures[picId - 1].Image.Height * 2;
//Calculating the width and height of picture frame
int pictureFrameWidth = 20;
int pictureFrameHeight = 20;
//Adding picture frame to the slide
slide.Shapes.AddPictureFrame(picId, pictureFrameWidth, pictureFrameHeight,
pictureWidth, pictureHeight);
// Adding second picture
pic = new Picture(pres, sPicPath + "Sunset.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
picId = pres.Pictures.Add(pic);
//Calculating picture width and height
pictureWidth = pres.Pictures[picId - 1].Image.Width * 2;
pictureHeight = pres.Pictures[picId - 1].Image.Height * 2;
//Calculating the width and height of picture frame
pictureFrameWidth = Convert.ToInt32(slideWidth -pictureWidth-20);// - pictureWidth / 4);
pictureFrameHeight =20;
//Adding picture frame to the slide
slide.Shapes.AddPictureFrame(picId, pictureFrameWidth, pictureFrameHeight,
pictureWidth, pictureHeight);
//Writing the presentation as a PPT file
// Adding 3RD picture
pic = new Picture(pres, sPicPath + "Water lilies.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
picId = pres.Pictures.Add(pic);
//Calculating picture width and height
pictureWidth = pres.Pictures[picId - 1].Image.Width * 2;
pictureHeight = pres.Pictures[picId - 1].Image.Height * 2;
//Calculating the width and height of picture frame
pictureFrameWidth = Convert.ToInt32(20);
pictureFrameHeight = Convert.ToInt32(slideHeight - pictureHeight - 20);// - pictureHeight / 4);
//Adding picture frame to the slide
slide.Shapes.AddPictureFrame(picId, pictureFrameWidth, pictureFrameHeight,
pictureWidth, pictureHeight);
// Adding 4th picture
pic = new Picture(pres, sPicPath + "Winter.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
picId = pres.Pictures.Add(pic);
//Calculating picture width and height
pictureWidth = pres.Pictures[picId - 1].Image.Width * 2;
pictureHeight = pres.Pictures[picId - 1].Image.Height * 2;
//Calculating the width and height of picture frame
pictureFrameWidth = Convert.ToInt32(slideWidth - pictureWidth-20);
pictureFrameHeight = Convert.ToInt32(slideHeight -pictureHeight -20);// - pictureHeight / 4);
//Adding picture frame to the slide
slide.Shapes.AddPictureFrame(picId, pictureFrameWidth, pictureFrameHeight,
pictureWidth, pictureHeight);
pres.Write(sPath + "modified.ppt");
As far as addition of group shapes is concerned, currently Aspose.Slides supports accessing of exisiting group shapes in PPT presentation only.
Thanks and Regards,