Free Support Forum - aspose.com

Last Slide Number

Alexey,

I would like to get the last slide number in a presentation.

I use Presentation.getFirstSlideNumber() to get the first slide number.
I thought I could use Slides.getLastSlidePosition() to get the last slide number, but it seems like it is returning the number of slides in the presentation.

How is getLastSlidePosition() different from Slides.size()?

Thank you,
Randy Stegbauer.

To get last slide number you should write:
int number = pres.getFirstSlideNumber() + pres.getSlides().getLastSlidePosition() - 1;

getLastSlidePosition() shows number of slides (without master slides) in a presentation.
Slides.size() is number of slides in the Slides collection. It’s equal to (normal slides + title master slides).

So if you have 10 slides in your presentation the getLastSlidePosition will return 10 but Slides.size() can return >= 10. It depends on number of title master slides in a presentation.