Reading PPT file

Hi,

I’ve several troubles when I try to read this ppt file.(I’ve attached the file with this message).
In fact, when I ran the code, I don’t match all slides. Yet, I use getSlideByPosition and getSlidePosition methods and my program run without problems on another ppt files.

The file has been created with MS Office 2003.

Besides, when I open this file with MS office 2007 or Open Office and I save it with XP ppt file format, and I restart to ran the code, I match all slides… I don’t understand…

No idea ?

Dear rbourgault,

Can you please clarify your problem? The number of normal slides should match with Presentation.getSlides().getLastSlidePosition().

Whereas Presentation.getSlides().size() returns the number of all slides including normal and masters.

Indeed, when I use the Presentation.getSlides () .getLastSlidePosition () method, I find the number of normal slides. In fact the problem is not here.

When I extract slides I obtain errors. The line which allows me to get back the slide is the following one:

for(int index=1;index<myPresentation.getSlides().getLastSlidePosition();++index) {
//…
Slide slide = myPresentation.getSlideByPosition( mySlides.get(index).getSlidePosition());
//…
}

This line produces me some errors: mySlides.get(index) .getSlidePosition()

The first results give me as index of ‘0’ , and i cannot work with this index seen that the position of a slide begins at 1. The code already creates work with several powerpoint files without problems .

I hope that you help me to resolve my problem.

There are two types of slides inside Presentation.getSlides()

Normal Slides
Master Slides

Position is valid only for Normal Slides. And position starts from 1 and goes equal to Presentation.getSlides().getLastSlidePosition(); So your loop condition will look like this.

for(int index=1;index<=myPresentation.getSlides().getLastSlidePosition();index++)

Notice, I used <= operator and post increment ++ operators inside loop.

Now, when you use this statement

mySlides.get(index).getSlidePosition()

Then the possibility exists, you are getting one of the master slides and then you are accessing its position, which is producing error. Your loop should be like this

for (int index = 1; index <= myPresentation.getSlides().getLastSlidePosition(); index++) {
    //...
    Slide slide = myPresentation.getSlideByPosition(index);

    //Not needed
    slide = myPresentation.getSlideByPosition(slide.getSlidePosition());

    //...
}