MS PowerPoint presentations can not be displayed directly from within the web or desktop applications. One of the possible solutions is converting the slides in a PPTX presentation to the images such as JPEG or PNG. In accordance with the above-mentioned scenario, this article will show you how to convert slides in a PPTX to JPG images using Java.
- PPTX to JPG Conversion API
- Convert PPTX to JPG Image using Java
- Customize Image Dimensions in PPTX to JPG Conversion
TIP:
To see a implementation of the conversion process described here, you may want to check out Aspose online PPT to JPG converter.
Java PPTX to JPG Image Conversion API
Aspose.Slides for Java is a presentation manipulation API that lets you implement PowerPoint automation features from within your Java applications. In addition, it also provides a PPTX to JPG image converter API to generate thumbnails of the slides in a presentation. You can either download the API or get it installed using the Maven configuration.
<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>
<classifier>jdk16</classifier>
</dependency>
PPTX to JPG Java Conversion
In order to convert the PPTX slides to JPG, you can simply loop through the slides in a presentation and save each of them as a JPG file. The following are the steps to perform this operation.
- Load the PowerPoint PPTX file using the Presentation class.
- Retrieve the slides in presentation using Presentation.getSlides() method.
- Access each slide using the ISlide interface.
- Get slide’s thumbnail into a BufferedImage object using ISlide.getThumbnail(1f, 1f) method.
- Save the BufferedImage as a JPG file.
The following code sample shows how to convert PPTX slide to JPG image using Java.
PowerPoint PPTX
Converted JPG Images
Java PPTX to JPG – Customize Image Dimensions
You can also customize the dimensions to scale the converted JPG images as per your desires. The following are the steps to specify the Scale X and Scale Y values in PPTX to JPG conversion.
- Load the PowerPoint PPTX file using the Presentation class.
- Specify the scaling values for the x-axis and y-axis using the slide’s width and height respectively.
- Retrieve the slides in presentation using Presentation.getSlides() method.
- Access each slide using the ISlide interface.
- Get slide’s thumbnail into a BufferedImage object using ISlide.getThumbnail(ScaleX, ScaleY) method.
- Save the BufferedImage as a JPG file.
The following code sample shows how to apply customized scaling in PPTX to JPG conversion.
Conclusion
In this article, you have learned how to convert slides in PPTX to JPG images using Java. Furthermore, you have seen how to apply the desired scaling to the images in PPTX to JPG conversion. You can learn more about the Java presentation manipulation API using documentation.