Free Support Forum - aspose.com

Find the first visible Slide in a PPT

Hi,

I create thumbnails from the first visible slide in a PPT.
Unfortunately this doesn’t work for all PPT Slides.

I create the thumbnail from the master slide if any present
in the PPT.

Which is the right way to access the first visible slide inside a
PPT? (not a master slide!)

Doesn’t work:
int index = part1.getFirstSlideNumber();
System.out.println(“FirstSlide:”+index);
System.out.println(“Slide Count:”+part1.getSlides().size());
BufferedImage img = part1.getSlideByPosition(index).getThumbnail(new Dimension(320,220));



Doesn’t work too:
BufferedImage img = part1.getSlideByPosition(0).getThumbnail(new Dimension(320,220));


Any working code available?!

greetings

Andreas

Dear Andreas,

To get normal slide, you should not get the reference to slide from Presentation.getSlides() collection rather use Presentation.getSlideByPosition() method. The position starts from 1.

Also, to know the number of normal slides (excluding slide masters or title masters), you can use Presentation.getSlides().getLastSlidePosition() method

For example, the code snippet below iterates all normal slides

for(int i=1; i<=srcPres.getSlides().getLastSlidePosition; i++)

{

Slide sld=srcPres.getSlideByPosition(i);

}

For working code and other examples, please see Progammer’s Section on Aspose.Slides Wiki. Please see, there is code in 4 languages, VB.NET, C#, JAVA and PHP. Don’t confuse C# with JAVA.

http://www.aspose.com/Wiki/Default.aspx/Aspose.Slides/

For thumbnails, you can directly go to this link.

http://www.aspose.com/Wiki/default.aspx/Aspose.Slides/CreatingSlideThumbnail.html

Thanks for the quick reply.

I used the wrong index. “Normaly” a java programmer
starts to count with “0”.

Greetings

Andreas