Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/9f9c8614b881fa83354e701d1a923a2a to your computer and use it in GitHub Desktop.
Save aspose-com-gists/9f9c8614b881fa83354e701d1a923a2a to your computer and use it in GitHub Desktop.
Generate Thumbnails for PowerPoint PPTX/PPT in Java
// Load PowerPoint presentation
Presentation presentation = new Presentation("presentation.pptx");
// User defined dimension
int desiredX = 1200;
int desiredY = 800;
// Getting scaled value of X and Y
float ScaleX = (float) (1.0 / presentation.getSlideSize().getSize().getWidth()) * desiredX;
float ScaleY = (float) (1.0 / presentation.getSlideSize().getSize().getHeight()) * desiredY;
// Iterate through the slides in the presentation
for (ISlide sld : presentation.getSlides()) {
// Create a full scale image of the slide
BufferedImage bi = sld.getThumbnail(ScaleX, ScaleY);
// Create a new file to save image
File outputfile = new File("Slide_" + sld.getSlideNumber() + ".png");
// Save image
ImageIO.write(bi, "png", outputfile);
}
// Load PowerPoint presentation
Presentation presentation = new Presentation("presentation.pptx");
// Iterate through the slides in the presentation
for (ISlide sld : presentation.getSlides()) {
// Create a full scale image of the slide
BufferedImage bi = sld.getThumbnail(1f, 1f);
// Create a new file to save image
File outputfile = new File("Slide_" + sld.getSlideNumber() + ".png");
// Save image
ImageIO.write(bi, "png", outputfile);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment