How to remove a specific PDF annotation or comment in Node.JS

Node.JS users rejoice! Your PDF annotation-related problems are about to become a distant memory.

Let’s install the client we are using first.

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

Next we are going to write up the code for calling editPdfRemoveAnnotationItem. If you look at the following example setup, you will see how we instantiate our API first using a key, then proceed to call the above function using that instance.

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 annotationIndex = 56; // Number | The 0-based index of the annotation in the documentvar callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.editPdfRemoveAnnotationItem(inputFile, annotationIndex, callback);

Boom! Already done! The rest of this library includes a great deal of other handy functions for working with PDFs (and other document formats), such as splitting pages, merging, and rasterization.

Image for post

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud 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