We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Problem accessing slide

Hi, can you check out this presentation in attachment. Problem is that there is only one slide in presentation, and Slides.size() returns two of them. Here is code snippet:
InputStream inputStream = getClass().getClassLoader()
.getResourceAsStream(path);

Presentation presentation = null;
try {
presentation = new Presentation(inputStream);
} catch (PptException e) {
e.printStackTrace();
}

Slides slides = presentation.getSlides();

int size = slides.size(); // returns 2

for (int i = 0; i < size; i++) {
Slide slide = slides.get(i);

System.out.println(slide); // this prints both slides
}

for (int i = 1; i <= size; i++) {
Slide slide = presentation.getSlideByPosition(i);

System.out.println(slide); // here code throws nullPointerException in second iteration
}

In one occasion one of your coleague told me to that the bast way to access slides is through
presentation.getSlideByPosition(); method

Thanks, Ivica.

Dear Ivica,

Slides collection contains Normal Slides as well as Title Masters, that's why, its count return true.

For normal slides count, you should use, Presentation.getSlides().getLastSlidePosition()