How to convert a PowerPoint PPTX to Text TXT in Node.JS

We are here today to look at how to extract all of the text out of a PowerPoint presentation using Node.JS. Straightforward enough, but how can we turn this task into a no-brainer? Well, that’s easy. We’ll use an API to do all the work for us!

We begin with installation of our client, accomplished with this reference added to our package.json file.

"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"
}

Now that we have access to our client, we can proceed to call our function as you see here:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentPptxToTxt(inputFile, callback);

Now just input your PPTX file and the API will convert it into text. Super easy.

Image for post
Image for post

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