How to Convert ODP to PDF using Node.js
Just like PowerPoint files, Open Document Presentation (ODP) files look great when they’re stored in PDF format. Plus — making this conversion ensures unwanted edits can’t be made to the original file.
Using the ready-to-run code below, we can easily equip our applications with a free API designed to convert ODP files into PDF format. This service processes files quickly in-memory (zero data retention) to main a high degree of security, and it can be used up to 800 times per month with no additional commitments when authorized with a free-tier API key.
We first need to install the SDK. We can do so in one of two ways — either by running the below command:
npm install cloudmersive-convert-api-client --save
Or by adding this snippet to our package.json:
"dependencies": {
"cloudmersive-convert-api-client": "^2.6.3"
}
After that, we can include the below examples in our file to structure our request & return our converted file content:
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.convertDocumentOdpToPdf(inputFile, callback);
That’s all there is to it — no more code required!