How to convert PowerPoint PPTX to PDF in Node.js

The first step here is to add a reference to the package.json for the document processing library:

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

Now, all we need to do is call convertDocumentPptxToPdf to convert a PowerPoint Document (PPTX) format file into a PDF file:

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) {
} else {
console.log('API called successfully. Returned data: ' + data);
apiInstance.convertDocumentPptxToPdf(inputFile, callback);

That’s it! And it’s free.

Note that there is also a function available for PPT format (the legacy PowerPoint binary file format), convertDocumentPptToPdf. You can also upgrade legacy PPT files to PPTX, convertDocumentPptToPptx.

You can also use an autodetect function to automatically detect the source format and convert it to PDF. You can also use this same library to read or modify the contents of the PPTX file, for example to add/remove slides, change headers, add images, etc.

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