Generate PPTX thumbnails in Java

Thumbnails are small-sized versions of the larger images that make it easier to look at or scroll through the list of images. MS PowerPoint also uses thumbnails for the presentations to go through the content and navigate to a particular slide. In this article, you will learn how to generate thumbnails of PowerPoint PPTX or PPT using Java. You can use this feature in scenarios such as while creating your web or desktop-based PowerPoint viewer.

Java API to Generate Thumbnails for PowerPoint PPTX/PPT

To generate thumbnails for PPTX or PPT presentations, we will use Aspose.Slides for Java. It is a feature-rich API for creating, manipulating, and converting PowerPoint and OpenOffice presentations. You can either download the API or install it using the following Maven configurations.

<repository>
    <id>AsposeJavaAPI</id>
    <name>Aspose Java API</name>
    <url>http://repository.aspose.com/repo/</url>
</repository>
<dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides</artifactId>
    <version>21.8</version>
    <classifier>jdk16</classifier>
</dependency>

Generate Thumbnails for PPTX or PPT using Java

The following are the steps to generate thumbnails of a PPTX presentation using Java.

  1. First, create an instance of the Presentation class to load the presentation.
  2. Loop through each ISlide in Presentation.getSlides() collection.
  3. Generate image of the each slide using ISlide.getThumbnail(1f, 1f) method and get the reference of image into a BufferedImage object.
  4. Create a new File for the output image.
  5. Finally, save the image using ImageIO.write(BufferedImage, String, File) method.

The following code sample shows how to generate thumbnails of a PPTX presentation using Java.

Generate Thumbnails with User-Defined Dimensions

You can also specify your own dimensions for the thumbnail images using the height and width of the slides. The following are the steps to perform this operation.

  1. First, create an instance of the Presentation class to load the presentation.
  2. Define the dimensions of the resultant PNG image.
  3. Loop through each ISlide in Presentation.getSlides() collection.
  4. Generate image of the each slide using ISlide.getThumbnail(float ScaleX, float ScaleY) method and get the reference of image into a BufferedImage object.
  5. Create a new File for the output image.
  6. Finally, save the image using ImageIO.write(BufferedImage, String, File) method.

The following code sample shows how to generate thumbnails of a PPTX with customized dimensions.

Get a Free API License

You can use Aspose.Slides for Java without evaluation limitations by requesting a temporary license.

Conclusion

In this article, you have learned how to generate thumbnails of PowerPoint PPTX or PPT using Java. Moreover, you have seen how to generate thumbnails with user-defined dimensions. In addition, you can visit the documentation to explore other features of API. Also, you can feel free to let us know about your queries via our forum.

See Also