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

Free Support Forum - aspose.com

Capturing GroupShapes as single Image


Please see attached powerpoint. In it all the shapes are ungrouped.
But I want to add them to a group and then use the method: slide.GetThumbnail(new object[] { shape }, imgSize, boundingRect) to capture that image as a single image. But I only want to do that to unGrouped Shapes, not TextFrames, etc.
Please tell how I can do that?

Hello,

You don’t need to group them, just create a collection object and add whatever shape you want to draw.

For example, in the code below, I add the shape in a list provided the shape does not have any textframe or if it has then it is empty.

Presentation pres = new Presentation(@"D:\downloads\helium_101_training_presentationUnGrouped.ppt");

Slide sld = pres.GetSlideByPosition(1);

//add the shape in a list provided the

//shape does not have any textframe

//or if it has then it is empty.

ArrayList lst = new ArrayList();

foreach (Shape shp in sld.Shapes)

{

if (shp.TextFrame == null)

{

lst.Add(shp);

}

else

{

if(shp.TextFrame.Text=="")

lst.Add(shp);

}

}

//Create an image with the included shapes only

int slideWidth = pres.SlideSize.Width;

int slideHeight = pres.SlideSize.Height;

System.Drawing.Rectangle rect = new System.Drawing.Rectangle(1,1,slideWidth,slideHeight);

Image img = sld.GetThumbnail(lst, 3.0, 3.0, rect);

//Save the image on disk

img.Save("c:\\out.jpg");

Also see the attached image generated by the above code.