This quick tutorial focuses on how to convert PNG to PowerPoint Slide in Java. It covers all the necessary information about the configuration, step-wise process, and a working sample code to write a PNG to PPTX converter in Java. The sample code exhibits the complete scenario and can be used in any of the Java configured operating systems like Windows, Linux, or macOS.
Steps to Convert PNG to PPTX in Java
- Configure the application by installing Aspose.Slides for Java from the Maven repository
- Instantiate the Presentation class object to add a default empty presentation
- Access the first default slide in presentation slides collection
- Load the PNG image from the disk and add it to the presentation image collection
- Insert the added image in a picture frame inside the shapes collection of the selected slide
- Save the presentation with PNG added as PPTX
The aforementioned steps guide to convert PNG to PPTX in Java whereby a new presentation is generated that has a default slide collection, image collection, and a save method to save the presentation on the disk. We access the desired slide by its index and then add an image to the presentation image collection by loading the source PNG image from the disk. Finally, the loaded image is added to a picture frame inside the shape collection of the selected slide.
Code to Convert PNG to PowerPoint in Java
In order to develop the application to convert PNG file to PowerPoint in Java, the Slide object is used to hold the reference to the desired slide and IPPImage object is used to hold the reference to the image added to the images collection. The addImage method comes with a number of overloaded constructors that take different parameters like Image object, bytes, IPPImage object and memory streams. You can also insert JPEG, GIF, BMP or other image formats inside the picture frame as well.
In this tutorial, we have explored to convert PNG to PPTX using Java. If you want to learn the process of adding PDF to PowerPoint presentations, refer to the article on how to convert PDF to presentation using Java.