How to split a single PowerPoint presentation PPTX into separate slides in Node.JS
Splitting PPTX files into separate slides in Node.JS is about as annoying of a task as you might think. But that’s only true if you are setting things up manually. If, on the other hand, you were to use an API, the results are almost instantaneous, as you are about to find out in today’s demonstration.
The following reference will install the client we need today when added to package.json.
"dependencies": {
"cloudmersive-convert-api-client": "^2.1.6"
}
And now we may set up our API instance and function call, as illustrated in this code example 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.SplitDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var opts = {'returnDocumentContents': true // Boolean | Set to true to return the contents of each presentation directly, set to false to only return URLs to each resulting presentation. Default is true.};var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.splitDocumentPptx(inputFile, opts, callback);
And now if you just enter your file path, you will have your individual slides returned to you in the response object. Alternatively, you may request your results as download URLs for convenience.