How to Convert PPTX to PDF in Node.js
Not everyone can open PPTX files on their machine, so it’s a great idea to have PDF versions of your presentations handy. Thankfully, the below API will make that file conversion easy. Just follow instructions to copy & paste complementary Node.js examples, and you’ll be ready to convert your PDF files in minutes.
First, install the SDK by either running the following command:
npm install cloudmersive-convert-api-client --save
Or copying this snippet to your package.json instead:
"dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}
Next, call the function:
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.convertDocumentPptxToPdf(inputFile, callback);
To satisfy the API key field, simply register a free account on our website and copy & paste your free-tier API key where prompted. Free-tier API keys provide a limit of 800 API calls per month with zero additional commitments (the total will reset the following month).