How to Convert PowerPoint to PNG in Node.js

Cloudmersive
2 min readDec 22, 2022

--

While PowerPoint is a widely used tool for creating complex presentations, its file type — PPTX — isn’t ideal for sharing. Converting your PowerPoint slides into PNG image files is a simple, easy way to get around this issue, and it provides the added benefit of protecting your final product against unwanted edits/changes too. The below code will make this conversion easy, programmatically converting large and small PowerPoints alike into organized PNG Image Arrays, with exactly one image per slide.

To take advantage of this API, simply copy from the ready-to-run Node.js code examples provided below to structure your API call. In addition to these examples, you’ll just need a free-tier Cloudmersive API key, which you can get by registering a free account on our website (with no commitments).

Let’s first run this command to install the SDK:

npm install cloudmersive-convert-api-client --save

After that, let’s call the function, supplying our presentation file & API key in the appropriate request parameters:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // 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);

That’s all there is to it!

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet