Total slides gives wrong value

Hi,


I am using aspose slides 2.6.0 and I want total number of slides in particular presentation.
I am using below code for the same. But somehow it gives me wrong number. Total number of pages in my ppt is 3 but it gives me 4.

Presentation pptPresentation = new Presentation(inputStream);
int total = pptPresentation.getSlides().size();

Any idea why its giving wrong value? Is it some issue with aspose slides ?

Please find attached ppt for which I am getting wrong value.

Hi Tejas,

I have observed the presentation shared by you. Actually, when you use Presentation.getSlides().size(), it will return all the slides in the slides collection that includes normal as well as master slides. This is why your slide count is returning 4. You may use the following properties two properties for selecting particular and maximum number of normal slides in PPT presentation.

pres.getSlides ().getLastSlidePosition ();

pres.getSlideByPosition (1);

Thanks and Regards,

Thanks a lot Mudassir for reply.

It really helps a lot. One more thing, Is every presentation has main slide in it?
As I noticed for some ppt pres.getSlides().size() returns proper value.

And if any ppt has main slide, is it always gone a be first slide only? or it can be any slide ?

Hi Tejas,

Every presentation does not necessarily have the Main master inside slides collection and that is why for some presentations, pres.getSlides().size() returns proper value. Moreover, the main slides is not necessarily the first slide. But the code snippet for getting maximum number of normal slides and accessing them with their position will save the day for you and work properly to avoid this inconvenience.

Thanks and Regards,