How to Convert a PDF to PDF/A in Node.JS

While PDF is a widely recognized document format, it is not always compatible with different platforms or other, international systems. Because of this, your document may not be presented the way that you planned when shared with others. To mitigate this, the following API will convert your PDF documents to PDF/A, a universally standardized PDF file format.

Image for post
Image for post

To use this API, run this command to install the SDK:

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

You can also add this snippet to your package.json:

"dependencies": {
"cloudmersive-convert-api-client": "^2.4.8"
}

Then, you can 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.EditPdfApi();var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // File | Input file to perform the operation on.var opts = {
'conformanceLevel': "conformanceLevel_example" // String | Optional: Select the conformance level for PDF/A - specify '1b' for PDF/A-1b or specify '2b' for PDF/A-2b; default is PDF/A-1b
};
var callback = function(error, data, response) {
if (error) {
console.error(error);
} else {
console.log('API called successfully. Returned data: ' + data);
}
};
apiInstance.editPdfConvertToPdfA(inputFile, opts, callback);

This will help improve not only your sharing capabilities but also boost the professional image of your documents.

You can retrieve the API Key from the Cloudmersive website at no cost and with no commitment. This will provide you with 800 monthly calls across our library of APIs.

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