How to convert PowerPoint PPTX to PDF in Javascript

PowerPoint presentations are definitely not a great fit for web display in their default format. A quick switch over to PDF format should help things run much more smoothly. Expeditious use of an API will help us get this done very quickly.

To use the API we need, import the client via this script tag:

<script src="https://cdn.cloudmersive.com/jsclient/cloudmersive-document-convert-client.js"></script>

With our API now accessible, we can proceed to call upon our function like this:

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

Yeah, that’s all there is to it. If you need support for legacy PPT format, we have another function specifically for that. For all your other document editing and conversion needs, check out our documentation for more ways to save yourself time.

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