Looping through slides - ordering issue



We have a new issue that is killing us - my developer and I are doing at this point, an utterly simple thing - opening a presentation, looping through all slides, and saving out jpegs using GetThumbnail.
What we get with the following code seems very random, the last slide appears first, and the count differs from the slide count when we open the presentation in powerpoint.


Dim pres As Aspose.Slides.Presentation = New Aspose.Slides.Presentation(filename)
Dim slide As Aspose.Slides.Slide

Dim sz As Size
sz.Height = 480
sz.Width = 640

Dim imgF As System.Drawing.Imaging.ImageFormat

For i = 0 To pres.Slides.Count - 1
fname = “C:\testfolder\images” & “slide” & i.ToString & “.jpg”
pres.Slides(i).GetThumbnail(sz).Save(fname, imgF.Jpeg)


as I said, the results are very random, jpeg version of slide 0 is blank, jpeg of slide 1 is the last slide in the presentation, jpeg of slide 2 is the first slide in the presentation, jpeg of slide 3 is slide 31 in actual presentation.

Obviously we are doing something utterly stupid here - I kindly ask that you please look at this and let us know where we have gone wrong.


That is because you didn’t read Programmer’s Guide and especially code examples.
Slides are not ordered and looping should be:

For i = 1 To pres.Slides.LastSlidePosition
fname = “C:\testfolder\images” & “slide” & i.ToString & “.jpg”
pres.GetSlideByPosition(i).GetThumbnail(sz).Save(fname, imgF.Jpeg)