Learn more about how to generate thumbnails of PowerPoint PPTX/PPT presentations using Java: https://blog.aspose.com/2021/08/03/generate-thumbnails-for-powerpoint-using-java/
Last active
September 3, 2021 06:15
-
-
Save aspose-com-gists/9f9c8614b881fa83354e701d1a923a2a to your computer and use it in GitHub Desktop.
Generate Thumbnails for PowerPoint PPTX/PPT in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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