In this simple topic, we will walk you through how to create PowerPoint Presentation using Java in MS Windows, macOS, or Ubuntu operating systems. This topic covers the detailed steps to set up the environment and by using a few lines of easy code in Java PPT presentation can be generated.
Steps to Generate PowerPoint Presentation in Java
- Download and install Aspose.Slides for Java from the Maven repository
- Instantiate the Presentation class object to create an empty presentation
- Create a blank slide and add that to the presentation slides collection
- Using the AddAutoShape method, insert a Rectangle shape in the newly created slide
- Insert a text frame using the addTextFrame method and set the text related properties
- Save the presentation on the disk in PPTX format
The aforementioned steps in Java create PPTX file on the disk using the simple API interface and with no dependence on PowerPoint. Firstly, an empty presentation is created using the Presentation class instance, which is followed by adding a blank slide inside the presentation. Then, a text frame is added inside the shape and its respective textual properties are set before saving the presentation on the disk using the save method.
Code to Create PowerPoint Presentation using Java
In Java presentation can be generated using a few lines of code as given in the above example. You may also save the presentation in the other formats like PPT, PPS, PPSX, ODP, POT and POTX using the SaveFormat enumerator. The text inside the presentation can be customized by using the different options exposed by the ParagraphFormat and PortionFormat classes which include setting the options like text wrapping, text autofit, indentations, margins, bullets, text highlighting and strike-through.
In this topic, we have learned how using Java PowerPoint presentation in different formats can be created. If you are interested in converting presentation slides to SVG, please visit the details mentioned in the article on how to convert PPTX to SVG using Java.