How to convert a PowerPoint PPTX to Text TXT in Java

Cloudmersive
1 min readAug 7, 2020

--

Sometimes big clunky formats like PPTX can cause problems with compatibility, etc. At times like these, you need a quick means of simply converting these files into a more friendly simple format, such as plain text. Instead of going the parsing route, which takes forever to set up, we will be taking a shortcut that will have us finishing up in no time at all.

First we need our repository reference for Jitpack.

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

Then our dependency reference for our client.

<dependencies>
<dependency>
<groupId>com.github.Cloudmersive</groupId>
<artifactId>Cloudmersive.APIClient.Java</artifactId>
<version>v3.54</version>
</dependency>
</dependencies>

And once our library is installed, we can proceed to call our function, as you see here.

// Import classes://import com.cloudmersive.client.invoker.ApiClient;//import com.cloudmersive.client.invoker.ApiException;//import com.cloudmersive.client.invoker.Configuration;//import com.cloudmersive.client.invoker.auth.*;//import com.cloudmersive.client.ConvertDocumentApi;ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: ApikeyApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");Apikey.setApiKey("YOUR API KEY");// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.setApiKeyPrefix("Token");ConvertDocumentApi apiInstance = new ConvertDocumentApi();File inputFile = new File("/path/to/file"); // File | Input file to perform the operation on.try {TextConversionResult result = apiInstance.convertDocumentPptxToTxt(inputFile);System.out.println(result);} catch (ApiException e) {System.err.println("Exception when calling ConvertDocumentApi#convertDocumentPptxToTxt");e.printStackTrace();}

Done!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

No responses yet