Convert PowerPoint to PNG
About PowerPoint to PNG Conversion
The PNG (Portable Network Graphics) format is not as popular as JPEG (Joint Photographic Experts Group), but it still very popular.
Use case: When you have a complex image and size is not an issue, PNG is a better image format than JPEG.
Tip
You may want to check out Aspose free PowerPoint to PNG Converters: PPTX to PNG and PPT to PNG. They are a live implementation of the process described on this page.Convert PowerPoint to PNG
Go through these steps:
- Instantiate the Presentation class.
- Get the slide object from the Presentation.getSlides() collection under the ISlide interface.
- Use a ISlide.getImage() method to get the thumbnail for each slide.
- Use the [IImage.save(String formatName, int imageFormat)](https://reference.aspose.com/slides/androidjava/com.aspose.slides/IImage#save(String formatName, int imageFormat)) method to save the slide thumbnail to the PNG format.
This Java code shows you how to convert a PowerPoint presentation to PNG:
Presentation pres = new Presentation("pres.pptx");
try {
for (int index = 0; index < pres.getSlides().size(); index++)
{
ISlide slide = pres.getSlides().get_Item(index);
IImage slideImage = slide.getImage();
try {
slideImage.save("image_java_" + index + ".png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
Convert PowerPoint to PNG With Custom Dimensions
If you want to obtain PNG files around a certain scale, you can set the values for desiredX
and desiredY
, which determine the dimensions of the resulting thumbnail.
This code in Java demonstrates the described operation:
Presentation pres = new Presentation("pres.pptx");
try {
float scaleX = 2f;
float scaleY = 2f;
for (int index = 0; index < pres.getSlides().size(); index++)
{
ISlide slide = pres.getSlides().get_Item(index);
IImage slideImage = slide.getImage(scaleX, scaleY);
try {
slideImage.save("image_java_" + index + ".png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}
Convert PowerPoint to PNG With Custom Size
If you want to obtain PNG files around a certain size, you can pass your preferred width
and height
arguments for ImageSize
.
This code shows you how to convert a PowerPoint to PNG while specifying the size for the images:
Presentation pres = new Presentation("pres.pptx");
try {
Dimension size = new Dimension(960, 720);
for (int index = 0; index < pres.getSlides().size(); index++)
{
ISlide slide = pres.getSlides().get_Item(index);
IImage slideImage = slide.getImage(size);
try {
slideImage.save("image_java_" + index + ".png", ImageFormat.Png);
} finally {
if (slideImage != null) slideImage.dispose();
}
}
} finally {
if (pres != null) pres.dispose();
}