Extract text from PowerPoint file (.ppt or .pptx)?

I am currently using a combination of OpenOffice macros and pdf2text program to extract text and would like to find an easier and more efficient way to get text from a PowerPoint file.

I tried using the Apache POI library and didn't have much luck, ran into numerous exceptions in the library when trying to parse the files I'm looking at and don't particularly want to sift through the library's source code.

Is there an easy way to do this without using the above library?

+1


a source to share


2 answers


If you have MS Office and you save PPT in RTF (Rich Text Format), it only contains the text from the presentation. Then you can open the file in any editor that understands RTF files and saves it as a text file (TXT).

I expect this to work from Open Office too.

Since you're talking about an API, this might not be for you, but it might give you new ideas on how to get there. Let's say you use multiple macros to perform the conversion step by step ...

Edit: I got curious and did a short google search



This is what I found on one of the www.openoffice.org pages

As the people in this thread pointed out, extracting text from an OO document is not difficult as it is just zipped xml that can be parsed with a perl script. The problem is getting Microsoft Powerpoint documents primarily zip XML format.

I found that File -> Wizards -> Document Convertor does exactly that. Just say you want to convert Powerpoint documents, not templates, point it to your source directory and where you want it to spit out the result and you're away.

Then I will find unzip -p $ file.sxi content.xml | perl -p -e "s / <[^>]> / \ n / g; s / + //; s / \ n \ n / \ n / g;" -w

works well enough for text extraction.

Sorry, I don't have Open Office to try any of these.

+1


a source


The pptx files are relatively easy to use because they are just zipped xml - you can just unzip them and then remove all xml tags from the contents of the files in the ppt / slides subdirectory in the unzipped stuff, yielding most of the relevant text.



ppt files are just a ball game, and the process turns out to be even more painful because the canonical tool, catppt from the catdoc package, is susceptible to buffer overflows, which makes it almost useless (it segfaults on a large percentage of ppt files).

+1


a source







All Articles