Convert PowerPoint to HTML in Java

powerpoint to html
Convert PowerPoint Presentations to HTML | PPT to HTML Conversion

PowerPoint presentations are widely used to communicate with your audience, where you add pictures, graphics, text, and videos for interactive sessions. They are used for multipurpose i.e. business, education, household, etc. Furthermore, in order to view them, we need specialized software. So a viable solution is the conversion of PowerPoint to HTML. In this article, we are going to discuss the details of how to convert PowerPoint to HTML using Java SDK.

PowerPoint Conversion API

Aspose.Slides Cloud SDK for Java is a REST-based API providing the capabilities to create, edit and convert PowerPoint presentations to HTML, PDF, XPS, JPEG, and a variety of other supported formats. Now in order to use the SDK in the Maven build project, please add the following details in pom.xml.

<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>22.4.0</version>
 </dependency>
</dependencies>

The next step is to create a free account by visiting Aspose.Cloud dashboard. If you have GitHub or Google account, simply Sign Up and obtain your client credentials.

Convert PowerPoint to HTML in Java

In this section, we are going to learn the details on how to load PowerPoint presentation stored in cloud storage and convert it to HTML format.

  • First, we need to create an instance of SlidesApi where we pass Client credentials as arguments
  • Secondly, create an object of File instance and load the source PowerPoint file
  • Now convert PowerPoint content to Byte[] array using readAllBytes(…) method
  • The next step is to upload PowerPoint to cloud storage using uploadFile(…) method
  • We need to create an instance of HtmlExportOptions where we can specify the presentation font
  • Now that we need to only convert slides at indexes 1 & 3, so we need to create a List object
  • Finally, call savePresentation(…) method of SlidesApi to convert PowerPoint to HTML and save the output in cloud storage
PowerPoint to Web Preview
Image 1:- PowerPoint to Web conversion preview.

PowerPoint to Web using cURL Commands

We can also convert Powerpoint presentations to HTML using cURL Commands. So the first step is to generate a JWT access token while executing the following command in the terminal application.

curl -v "https://api.aspose.cloud/connect/token" \
-X POST \
-d "grant_type=client_credentials&client_id=bbf94a2c-6d7e-4020-b4d2-b9809741374e&client_secret=1c9379bb7d701c26cc87e741a29987bb" \
-H "Content-Type: application/x-www-form-urlencoded" \
-H "Accept: application/json"

Now that we have the JWT token, we need to run the following command to load PowerPoint from cloud storage and convert it to HTML format. The resultant file is then stored on a local drive.

curl -v -X POST "https://api.aspose.cloud/v3.0/slides/Resultant.ppt/Html" \
-H  "accept: multipart/form-data" \
-H  "authorization: Bearer <JWT Token>" \
-H  "Content-Type: application/json" \
-d "{  \"DefaultRegularFont\": \"string\",  \"FontFallbackRules\": [    {      \"RangeStartIndex\": 0,      \"RangeEndIndex\": 0,      \"FallbackFontList\": [        \"string\"      ]    }  ],  \"Format\": \"string\"}"

Conclusion

In this article, we have explored the details of converting PowerPoint Presentations to Web using Java code snippets as well as through cURL commands. You have observed that with few code lines, the whole conversion process is completed, and the resultant HTML is saved to Cloud storage. Please note that the complete source code of SDK is available for download over GitHub. Nevertheless, if you encounter any issue while embedding HTML in PowerPoint or you have any further queries, please feel free to contact us via the free technical support forum.

Related Articles

We highly recommend visiting the following links to learn about: