Retrieve text from PPTX file (for Java)

I am looking for an example on getting all the text from a PPTX file. I keep finding examples for C# or for PPT and Java. Could you please provide me with an example on doing this in Java?

Todd

Hi Todd,

Thanks for considering Aspose.Slides.

We are working on your problem and will get back to you ASAP with solution.

We apologize for the delay and feel sorry for your inconvenience,

Hi Todd,

Thanks for wating this much longer.

Please use the code snippet below for extracting text from each slide in PPTX presentation. I have executed and tested the code with Aspose.Slides for Java 2.2.0. I have also attached the source PPTX file for your reference as well.

try
{
    PresentationEx presentation=new PresentationEx("C:\\HelloWorld.pptx");
    for (int index=0;index<presentation.getSlides().size();index++)
    {
        SlideEx slideEx = presentation.getSlides().get(index);
        ShapesEx shps=slideEx.getShapes();
        for (int sh = 0; sh < shps.size(); sh++)
        {
            ShapeEx shape = shps.get(sh);
            if(shape instanceof AutoShapeEx )
            {
                AutoShapeEx aShp = (AutoShapeEx)shape;
                if (aShp.getTextFrame() != null){
                    TextFrameEx tf=aShp.getTextFrame();
                    for(int pg=0;pg<tf.getParagraphs().size();pg++)
                    {
                        ParagraphEx Paragraph=tf.getParagraphs().get(pg);
                        for(int pt=0;pt<Paragraph.getPortions().size();pt++)
                        {
                            String sts=Paragraph.getPortions().get(pt).getText();
                            System.out.println(sts+"\n");
                        }
                    }
                }
            }
        }
    }
}
catch(IOException e)
{
    e.printStackTrace();
}

Thanks and Regards,