Free Support Forum - aspose.com

How to find type of shapes present on the PPT

Hello,

I want to retrieve the type(name) of shapes present on the slide.
eg. <!–[if gte mso 10]>

/* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-parent:""; mso-padding-alt:0in 5.4pt 0in 5.4pt; mso-para-margin:0in; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:10.0pt; font-family:"Times New Roman";}

<![endif]–><span style=“font-size: 12pt; font-family: “Times New Roman”;”>The structure of the Aspose.Slides for Java DOM shows that under the shape there are four different objects
1. Line
2. Eclipse
3. Rectangle
4. TextFrame
5. PictureFrame.

from the below code
def tf = shapes.get(j).getTextFrame()

I am able to get the text frame , but there is no such method to find the pictureframe or in which shape I am

Please let me know how can I find the Shape type.

Thanks
Rahul

Dear Rahul,

You can identify the different shapes in PPT. However, the text frame can be contained inside Rectangle or Ellipse. Please use the following code snippet to achieve the task requested in your post. For your kind reference, I have also attached thee source presentation as well.

Presentation Pres= new Presentation("D:\\MyShape.ppt");
Slide sld=Pres.getSlides().get(0);
Shape shp;

for(int i=0;i<sld.getShapes().size ();i++)
{
shp=sld.getShapes().get (i);
if(sld.getShapes().get (i) instanceof PictureFrame)
{
System.out.println ("Shape is Picture Frame");
}
else if(shp instanceof Rectangle)
{
System.out.println ("Shape is Rectangle");

if(shp.getTextFrame ()!=null && !shp.getTextFrame().getText ().isEmpty())
{
System.out.println ("Shape text is :"+shp.getTextFrame().getText ());
}
}
else if(shp instanceof Ellipse)
{
System.out.println ("Shape is Ellipse");

if(shp.getTextFrame ()!=null && !shp.getTextFrame().getText ().isEmpty())
{
System.out.println ("Shape text is :"+shp.getTextFrame().getText ());
}

}
else if(shp instanceof Line)
{
System.out.println ("Shape is Line");
}
}

Thanks and Regards,

Hi,

Thanks for the quick reply , the code shared by you was additional help.

Thanks
Rahul