Free Support Forum - aspose.com

Extracting from Powerpoint/ppt files

I’m having trouble finding sample code to do the following (the code I did find in this forum did not work, some methods and properties referred to by the code were not there, so I wonder if they were using a different version of the library)

1. Save embedded attachments (OLE objects) as separate files
2. Create tiff (or png) image of a ppt file
3. Save (semi-formatted) text of a ppt file

My project is in Java, so I’d rather use the Java version, but from looking at the documentation, the Java libraries are lagging behind, so I may have to use the .net versions. Please advise…
Q1. What is the timeframe before the Java libraries catch up?
Q2. Are the .net versions more active–are they always be more up to date and have the latest bug fixes?

  1. I found some code for saving the embedded attachments (OLE objects), but need to find out how to determine if the OLE object is iconized or displayed inline (if it’s inline, I don’t want to extract it).

    2. I’m not sure if the Java version supports this yet. Any answers?

    3. I saw another post for extracting text, though it mentioned problems extracting text from tables. Any definitive answers?

    I would also appreciate answers on the timeframe for Q1/Q2. I got responses for the other components (Word, Cells), but not from Shapes yet.

Hi,

1) You can determine whether an embedded OLE Object is iconized or not using OleObjectFrame.isObjectIcon().

2) To extract all the text including tables from a presentation using Aspose.Slides for Java, following is an example code:

try {

Presentation pres=new Presentation("textppt.ppt");

for(int i=1;i<pres.getSlides().size();i++)

{

Slide sld=pres.getSlideByPosition(i);

for(int j=0;j<sld.getShapes().size();j++)

{

Shape shp=sld.getShapes().get(j);

if(shp.getPlaceholder() != null && shp.isTextHolder() == true)

{

TextHolder thld = (TextHolder)shp.getPlaceholder();

System.out.println(thld.getText());

}

else if(shp instanceof com.aspose.slides.Rectangle)

{

com.aspose.slides.Rectangle rect=(com.aspose.slides.Rectangle)shp;

if(rect.getTextFrame() != null)

{

System.out.println(rect.getTextFrame().getText());

}

}

else if(shp instanceof GroupShape)

{

GroupShape gshp=(GroupShape)shp;

for(int k=0;k<gshp.getShapes().size();k++)

{

Shape shp1=gshp.getShapes().get(k);

if(shp1.getPlaceholder() != null && shp1.isTextHolder() == true)

{

TextHolder thld = (TextHolder)shp1.getPlaceholder();

System.out.println(thld.getText());

}

else if(shp1 instanceof com.aspose.slides.Rectangle)

{

com.aspose.slides.Rectangle rect=(com.aspose.slides.Rectangle)shp1;

if(rect.getTextFrame() != null)

{

System.out.println(rect.getTextFrame().getText());

}

}

}

}

}

}

} catch (PptException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (FileNotFoundException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}