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 PowerPoint PPT to PNG in Java. We will demonstrate how to convert each slide in a PPT or PPTX to PNG image in Java.
- Java PowerPoint PPT to PNG Converter - Free Download
- Steps to Convert PowerPoint PPT to PNG
- Convert PowerPoint PPTX to PNG in Java
Java PowerPoint PPT to PNG Converter - Free Download
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>22.7</version> <classifier>jdk16</classifier> </dependency>
Steps to Convert PPT to PNG in Java
Aspose.Slides for Java provides the simplest way of converting slides in PowerPoint PPT to PNG images. The following are the steps that you need to perform for PPT to PNG conversion in your Java applications.
- Load the PPT/PPTX presentation from disk.
- Set dimensions of output PNG image.
- Convert each slide in PPT to a PNG image.
- Save PNG image file on disk.
Let’s now transform these steps into the code to see how to convert a PPTX file to PNG in Java.
Convert a PPTX to PNG in Java
The following are the steps to convert slides in a PowerPoint PPTX to PNG in 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 PPTX to PNG in Java.
PowerPoint to PNG Java Converter - Get a Free License
You can use Aspose.Slides for Java without evaluation limitations by getting a free temporary license.
Save PPTX as PNG - Online Demo
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 in 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.