Convert PPTX to JPG online. PPT to PNG conversion in Java

PPT to JPG conversion

MS PowerPoint enables the user to create dynamic, informational slides through the use of text, graphics, and animation. Such visual and audio cues may also help a presenter be more improvisational and interactive with the audience. Owing to these features, the PPT / PPTX / OTP / ODP, etc have become very popular for information presentation. However, in order to view or edit these files, specific applications are required and they vary from platform to platform. It gets even complicated when you simply need to view the PPT / PPTX on a mobile device because for that purpose, you will need to search and install a related App. Therefore, the conversion into standard raster images can be much viable option. In this article, we are further going to discuss how to convert PPTX to JPG online.

PowerPoint processing REST API

Aspose.Slides Cloud SDK for Java is a wrapper around Aspose.Slides Cloud which provides the capabilities to create, edit and render PowerPoint slides to other Supported Document Formats. You can perform all the processing in the cloud. No software download or installation required. But in order to programmatically use the SDK, we need to install it over the system. It is available for download over Maven and GitHub. Please enter the following details in pom.xml of the maven build project to install the SDK.

<repositories>
 <repository>
        <id>aspose-cloud</id>
        <name>artifact.aspose-cloud-releases</name>
        <url>http://artifact.aspose.cloud/repo</url>
    </repository>   
</repositories>
<dependencies>
 <dependency>
    <groupId>com.aspose</groupId>
    <artifactId>aspose-slides-cloud</artifactId>
    <version>21.3.0</version>
 </dependency>
</dependencies>
aspose-slides-cloud.jar

Now in order to use the SDK, the next step is to obtain your personalized ClientID and ClientSecret details. Therefore, the first step is to create an account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up. Otherwise, click on the Create a new Account button and provide the required information. Now login to the dashboard using credentials and expand the Applications section from the dashboard and scroll down towards the Client Credentials section to see Client ID and Client Secret details.

Client Credentials

Render PPTX to JPG in Java

In order to render the PowerPoint presentation in JPG format, please follow the steps defined below.

  • First of all, create an object of SlidesApi while providing ClientID and ClientSecret details as arguments
  • Secondly, create an object of PutSlideSaveAsRequest class
  • Thirdly, call the setFormat(…) method of PutSlideSaveAsRequest and pass JPEG value from SlideExportFormat enumeration
  • Now call the setName(…) method of PutSlideSaveAsRequest class to provide name of input PPTX file
  • In order to specify the name of the resultant file, use the setOutPath(…) method from PutSlideSaveAsRequest class
  • Penultimate, call the setSlideIndex(..) method to specify the index of PowerPoint slide to be converted
  • Finally, call the putSlideSaveAs(…) method of SlidesAPi class and pass PutSlideSaveAsRequest object as argument
PPTX to JPEG conversion

The sample files used in above example can be downloaded from following links

Convert PPT to PNG in Java

In the following example, we are going to discuss the details on how to upload a PowerPoint presentation from a local system and convert it to PNG format in the cloud.

  • First, we need to create an object of SlidesApi which takes ClientID and ClientSecret as input arguments
  • The next step is to load a Presentation file from local storage into byte[] array
  • Create an instance of PutExportSlideRequest class
  • In order to specify the output format, please use setFormat(….) method of PutExportSlideRequest class and pass PNG value from SlideExportFormat enumeration
  • The input file is passed using setDocument(…) method which takes byte[] array as an argument
  • Now we need to specify the index of the slide to be converted using the setSlideIndex(..) method
  • In order to specify the name of the resultant file, use the setOutPath(…) method
  • Finally, call the putExportSlide(…) method which takes the PutExportSlideRequest object as an argument to perform the conversion
PPT to PNG conversion

The sample input and output files used in above example are available for download on following links

cURL command for PPTX to JPG conversion

The cURL commands are an exciting way to access REST APIs on any platform. Since Aspose.Slides Cloud is developed according to REST architecture, so you can access it using cURL commands to perform the conversion operations. Now the next step is to generate JSON Web Token (JWT) based on your ClientID and ClientSecret details retrieved from Aspose.Cloud dashboard. Please execute the following command in the terminal to generate the JWT token.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=718e4235-8866-4ebe-bff4-f5a14a4b6466&client_secret=388e864b819d8b067a8b1cb625a2ea8e" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Once we have the JWT token, use the following command to convert existing PowerPoint in Cloud storage to JPEG format. We have used PostSlidesSplit API which splits the presentation file and creates an image of each slide. In our scenario, we have provided a range from slides 1 to 1.

curl -X POST "https://api.aspose.cloud/v3.0/slides/Presentation1.pptx/split?format=Jpeg&from=1&to=1" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"DefaultRegularFont\": \"string\",  \"Format\": \"jpeg\"}"

Convert PPT to PNG using the cURL command

The slides of PowerPoint presentation can be easily converted to PNG format. Use the following command to perform the conversion.

curl -X POST "https://api.aspose.cloud/v3.0/slides/Presentation1.pptx/split?format=Png&width=1000&height=600&from=1&to=1" \
-H  "accept: application/json" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"DefaultRegularFont\": \"string\",  \"Format\": \"png\"}"

Conclusion

This article has explained an exciting feature of Aspose.Slides Cloud SDK for Java to convert PowerPoint slides to raster images (JPEG & PNG). Apart from conversion to raster image formats, you also get the features to Create new PowerPoint Presentations, Split PowerPoint Presentations and Merge PowerPoint Presentations, etc.

The Cloud SDK is open-source and its complete source code is available on GitHub. In case you encounter any issues while using the SDK, please feel free to contact us through the Free customer support forum.

Related articles

We also recommend visiting following links for details on