Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PPTX to PNG image using Apache POI
import org.apache.poi.xslf.usermodel.XMLSlideShow;
import org.apache.poi.xslf.usermodel.XSLFSlide;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
public class Transcoder {
public static void main(String args[]) throws IOException{
//creating an empty presentation
File file=new File("sample-ppt-for-converter.pptx");
XMLSlideShow ppt = new XMLSlideShow(new FileInputStream(file));
//getting the dimensions and size of the slide
Dimension pgsize = ppt.getPageSize();
java.util.List<XSLFSlide> slide = ppt.getSlides();
for (int i = 0; i < slide.size(); i++) {
BufferedImage img = new BufferedImage(pgsize.width, pgsize.height,BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = img.createGraphics();
//clear the drawing area
graphics.fill(new Rectangle2D.Float(0, 0, pgsize.width, pgsize.height));
//creating an image file as output
FileOutputStream out = new FileOutputStream("ppt_image_" + i + ".png");
javax.imageio.ImageIO.write(img, "png", out);
System.out.println("Image successfully created");

This comment has been minimized.

Copy link

jaluDadhich commented Jul 30, 2019

How do you convert the .ppt to image , Please share the answer


This comment has been minimized.

Copy link
Owner Author

aautar commented Aug 4, 2019

You can try the code above, but I remember encountering a number of issues with Apache POI rendering slides.. but things may have changed since 2017 🤷‍♂️

We ended up using the Zamzar API ( which worked well for us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.