How to convert a PowerPoint PPTX to a PNG Array in Node.JS

Sometimes PowerPoint files can be much less convenient to work with than simple PNG images. Today’s quick lesson will cover how to make the format conversion between these two as easy as it can possibly be. With an API as our starting point, this will be a piece of cake.

So to kick things off, add the following reference to package.json.

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

That will install our client, which will allow us to proceed with calling our conversion function, like so:

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.convertDocumentPptxToPng(inputFile, callback);

Well, would you look at that, we have already completed our goal. By simply passing files into this function, we can easy convert between our two formats. For additional format options and more great functions, look at the rest of what this library has to offer.

Image for post

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