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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
//your code here...
Presentation pres = new Presentation(path+"TestPres.ppt");
//iterate all slides
int lastSlidePosition = pres.getSlides().getLastSlidePosition();
for (int pos = 1pos <= lastSlidePositionpos++)
{
    Slide sld = pres.getSlideByPosition(pos);
    //iterate all shapes
    int shapesCount = sld.getShapes().getCount();
    for (int shpIdx = 0shpIdx < shapesCountshpIdx++)
    {
        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
X

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