How to Extract Entire Text from PowerPoint Presentation inside Android Apps
This technical tip explains how Android developers can extract entire text from a presentation inside Android applications using Aspose.Slides for Android. You can extract text from presentation using Aspose.Slides for Android. The text inside a presentation is located in two types of objects namely TextHolder and TextFrame. TextHolder is a special Placeholder that holds text and TextFrame is actually a TextBox which you create using MS-PowerPoint. Aspose.Slides for Android has designed the layout of TextHolder and TextFrame almost identical so that programmers could access and manipulate text easily.
//your code here...
Presentation pres = new Presentation(path+"TestPres.ppt");
//iterate all slides
int lastSlidePosition = pres.getSlides().getLastSlidePosition();
for (int pos = 1; pos <= lastSlidePosition; pos++)
{
Slide sld = pres.getSlideByPosition(pos);
//iterate all shapes
int shapesCount = sld.getShapes().getCount();
for (int shpIdx = 0; shpIdx < shapesCount; shpIdx++)
{
com.aspose.slides.Shape shp=sld.getShapes().get_Item(shpIdx);
//Get the paragraphs from textholder or textframe
Paragraphs paras = null;
//Check if shape holds a textholder
if (shp.getPlaceholder() != null && shp.isTextHolder() == true)
{
//Get the place holder as an Object instance
Object obj = shp.getPlaceholder();
//First type of place holder. It is TextHolder
if(obj instanceof TextHolder)
{
//Cast object into TextHolder object
TextHolder txtHolder = (TextHolder)obj;
paras = txtHolder.getParagraphs();
//iterateParagraphs(paras, portionList);
}
else if(obj instanceof Placeholder) //Second type of place holder(Shape)
{
//Cast the object into Placeholder object
Placeholder placeHolder = (Placeholder)obj;
// getShapeRef() returns the Shape object which contains real properties of a Placeholder.
paras = placeHolder.getShapeRef().getTextFrame().getParagraphs();
//iterateParagraphs(paras, portionList);
}
}
else
{
if (shp.getTextFrame() != null)
{
paras = shp.getTextFrame().getParagraphs();
}//if
}//else
//Print the text on Console
if (paras != null)
{
int parasCount = paras.getCount();
for (int paraIdx = 0; paraIdx < parasCount; paraIdx++)
{
Paragraph para = paras.get_Item(paraIdx);
//print the text on console
Log.i(TAG,"Para text : "+para.getText());
}
}//end if
}//end for
}//end for
Url: http://www.aspose.com/android/powerpoint-component.aspx
Language: Java | User: Sheraz Khan | Created: Mar 18, 2015 | Tags: Extract Text from Presentation Extract Entire Text from PPT files Text extraction from Slides Export PT/PPTX to PDF Android PPT API Android PowerPoint