How to Convert PDF to PDF/A in Node.js

2 min readSep 29


Before we commit PDF documents to a long-term storage location, we should consider converting them to PDF/A format. After all, PDF/A is the ISO standard solution for electronic document archiving.

Thankfully, we don’t have to rely on an expensive solution to accomplish large scale PDF to PDF/A conversions.

Using the below code, we can take advantage of a free API that will allow us to convert our PDF documents to either PDF/A-1b or PDFA-2b. We can select either of these options by specifying ‘1b’ or ‘2b’ in our request (default is PDF/A-1b).

To call this API for free, we’ll first need to obtain a free-tier API key. We can get one by registering a free account on the Cloudmersive website; this will allow us to make up to 800 API calls per month with no commitments.

After that, we can install the SDK by either running the following command:

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

Or by adding the following snippet to our package.json:

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

Finally, we can copy the below ready-to-run Node.js code examples into our file, and we can incorprate our PDF form data & our api key to complete our request:

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

That’s all the code we’ll need to make our conversion. Easy!




There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.

Recommended from Medium


See more recommendations