Use Case: I want to convert PPTX file slides into images and post it into my website

I am searching for a library to convert PPTX slides into Images(jpg, png). Suggest me a good java library.

I have tried POI jar, But I am getting alignment and color issues.


Spire.Presentation for Java library can be used to convert ppt/pptx to images (for instance, jpg, png, tiff, bmp).

Apart from conversion, the library also supports lots of other manipulations, such as add animations, secure ppt/pptx, add shapes/comments/hyperlinks, create table/chart, add SmartArt graphics and many more. You can explore more about it by visiting the documentation.

Here is an example shows how to convert a pptx file to images.

import com.spire.presentation.Presentation;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;

public class ToImage {
    public static void main(String[] args) throws Exception {

        Presentation ppt = new Presentation();
        //Save pptx file to images
        for (int i = 0; i < ppt.getSlides().getCount(); i++) {
            BufferedImage image = ppt.getSlides().get(i).saveAsImage();
            String fileName = String.format("ToImage-%d.png", i);
            ImageIO.write(image, "PNG",new File(fileName));


Try using Apache POI


Also look at https://stackoverflow.com/questions/6227275/convert-file-pptx-to-image-using-java

  • Thank you Clinton P. Jul 27 '19 at 8:38

Aspose.slides is generating accurate images from PPT. But it is not an open-source

Link: Aspose.Slides


You can use LEADTOOLS Document SDK technology in your application. https://www.leadtools.com/sdk/products/document

You can leverage the RasterCodecs class, which does not require the Microsoft Office interop assemblies, to load each PPT/PPTX slide as a raster image and export each page to JPEG or PNG.

DISCLOSURE: I am an employee of the company offering this toolkit. Also, I did notice this question was a little bit older but the information in this post is for anyone else looking for something similar.

Here is some sample code:

RasterCodecs _codecs = new RasterCodecs();
int totalPages = _codecs.getTotalPages(_multipagePPTX);
for(int i = 1; i <= totalPages; i++)
    String _outputFile = "<FILE_DIRECTORY>\\PPTX(page " + i + ").png";
    RasterImage _image = _codecs.load(_multipagePPTX, i);
    _codecs.save(_image, _outputFile, RasterImageFormat.PNG, _image.getBitsPerPixel());

The link below contains a tutorial written in Java that shows how to create an application that utilizes the RasterCodecs class.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.