The conversion of PowerPoint presentations to image formats could be used in various scenarios. For example, to display the presentations in your web or desktop applications, to generate thumbnails, etc. Since PNG is one of the most popular image formats, in this article, you will learn how to convert slides in PowerPoint PPTX or PPT to PNG images using Java.
Java API for PowerPoint to PNG Conversion
For PPTX or PPT to PNG conversion, we will use Aspose.Slides for Java. The API lets you create, manipulate and convert PowerPoint and OpenOffice presentations from within the Java applications. 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>
Convert PowerPoint PPTX or PPT to PNG in Java
The following are the steps to convert slides in a PowerPoint PPTX to PNG images using Java.
- First, create an instance of the Presentation class to load the presentation.
- Define the dimensions of the resultant PNG image.
- Loop through each ISlide in Presentation.getSlides() collection.
- Generate image of the each slide using ISlide.getThumbnail(float ScaleX, float ScaleY) method and get the reference of image into a BufferedImage object.
- Create a new File for the output PNG image.
- Finally, save the PNG image using ImageIO.write(BufferedImage, String, File) method.
The following code sample shows how to convert a PowerPoint PPTX to PNG.
Get a Free API License
You can use Aspose.Slides for Java without evaluation limitations by requesting a temporary license.
Try the online PowerPoint to PNG converter, which is based on Aspose.Slides.
In this article, you have learned how to convert slides in PowerPoint PPTX or PPT to PNG using Java. You can simply install the API and use the provided code in your Java applications. 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.