poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mihali A. Felipe" <mihali.fel...@yale.edu>
Subject HSLF getting text from each slide in sequence
Date Sun, 30 Apr 2006 02:31:45 GMT

Hi. I'm new to POI and am getting a little perplexed. I'm trying to do 
something seemingly simple - getting text from each slide in sequence 
while keeping track of which slide the text is from. However, the slides 
do not show up in sequence (and it seems like some slides are repeated 
e.g. try it on 
http://www.gersteinlab.org/lectures/ppt/A2K-at-Yale-20060422.ppt). Also, I 
don't know where/how to get the real slide number.

There seems to have been a related discussion here

http://mail-archives.apache.org/mod_mbox/jakarta-poi-user/200603.mbox/%3cOF21AF1CF1.02F9A527-ON8625713B.006E02A7-8625713B.006E5374@us.ibm.com%3e

but I'm having difficulty following it (too many dead brain cells I 
guess). My code is below. Could you tell me what i'm doing wrong and how 
to fix it? Thanks!

P.S. Why does getSheetNumber() keep giving me -1?

//-----------------------------------------------
import org.apache.poi.hslf.HSLFSlideShow;
import org.apache.poi.hslf.usermodel.*;
import org.apache.poi.hslf.model.*;

public class ppt2txt {

     public static void main(String[] args) {

         try{
        HSLFSlideShow fn = new HSLFSlideShow (args[0]);
        SlideShow ss = new SlideShow (fn);
        Slide[] sa = ss.getSlides();

        for (int i = 0; i < sa.length; i++) { //for each slide

        TextRun[] tr= sa[i].getTextRuns();

        for (int j = 0; j < tr.length; j++) { //for each slide

        String test = tr[j].getRawText();
        System.out.println(test);
        }

        System.out.printf("\n%d\n--------------NEXT SLIDE-----------------\n", sa[i].getSheetNumber());
        }
        } catch (java.io.IOException junk) { System.out.println(junk);
         }
     }

}
//-----------------------------------------------



- Mihali

----
.  Mihali A. Felipe
.  Gerstein Lab : Bioinformatics
.  Yale University Molecular Biophysics and Biochemistry
.  203-432-6337


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Mime
View raw message