Working in Groupobjects in slides using java

Hi Team,

I wanted to know the following code snippets using aspose slide . I am using java and aspose slides version 3.0

1) How to create group objects in slides?
2) How to remove shapes from group objects?
3) How to add shapes in group objects?
4) I have group objects which includes one ole object and other shapes. When I increased width of the group, only ole shape width is increased not other shapes.

Can you help me to achieve the above requirements.

Thanks.

Hi Senthil Kumar,


Thanks for inquiring Aspose.Slides.

I have observed your requirements and like to share that Aspose.Slides offers to manage the groups shapes as other normal shapes. In fact, like shape collection for any slide a group shape in any slide has its own collection of shapes inside it. At present, Aspose.Slides does not possess the feature for adding group shapes from scratch using Aspose.Slides. However, you can use a template slide with any sample group shape and then access that using Aspose.Slides. Then you can add, remove or even update the shapes inside any group shape like other normal shapes. The trick lies in accessing the group shape and then accessing the shapes inside that group shape. Please use the following code snippet to serve the purpose.

public static void MangeGroupShape() throws Exception
{
// Instantiate PresentationEx class that represents PPTX
PresentationEx pres = new PresentationEx(“D:\Aspose Data\TestGroup.pptx”);

// Access first slide
SlideEx sld = pres.getSlides().get_Item(0);

// Iterate through shapes to find the placeholder
for (int i = 0; i < sld.getShapes().size(); i++)

{
ShapeEx shp=sld.getShapes().get_Item(i);
if(shp instanceof GroupShapeEx)
{
//Getting AutoShape from group shapes set
GroupShapeEx gShape = (GroupShapeEx)shp;
int ind=gShape.getShapes().addAutoShape(ShapeTypeEx.Rectangle,300,200,100,100 );
ind=gShape.getShapes().addAutoShape(ShapeTypeEx.Ellipse,600,300,100,100 );
//Now see how to remove the shape from group shape
gShape.getShapes().removeAt(1);
System.out.println("Shapes inside group shape: "+Integer.toString(gShape.getShapes().getCount()));

}

}

// Write the PPTX to Disk
pres.write(“D:\Aspose Data\GroupShape.pptx”);
}

I also like to add that if you increase the group shape size, it does not mean the shapes inside that group shape will be adjusted automatically. You need to access the respective shapes inside group shape and adjust them accordingly. Please share, if I may help you further in this regard.


Many Thanks,