How to convert a PowerPoint PPTX to Text TXT in Java

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.


Then our dependency reference for our client.


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();}


Written by

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

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store