How to enumerate PDF Form Fields and Values in Node.JS

Cloudmersive
1 min readApr 22, 2020

The following tutorial will allow you to extract a list of fields from PDF forms and their respective data values. The process is actually quite easy, as you will soon see.

We start by adding this reference to our package.json, which allows our client installation to begin.

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

The next step is a function call for editPdfGetFormFields:

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

And now we just add our PDF file as the input and we will receive our list of fields and other data. From there we can use the sister function editPdfSetFormFields to input data into each of these fields.

--

--

Cloudmersive

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