How to remove a specific PDF annotation or comment in C# .NET Framework

Cloudmersive
1 min readFeb 23, 2020

Let’s begin the process by running this command in our Package Manager console. This will install our API client via NuGet.

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 2.2.0

Once that has completed, we shall proceed with invoking EditPdfRemoveAnnotationItem and providing the index number of our annotation.

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class EditPdfRemoveAnnotationItemExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new EditPdfApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.var annotationIndex = 56;  // int? | The 0-based index of the annotation in the documenttry{// Remove a specific PDF annotation, comment in the documentbyte[] result = apiInstance.EditPdfRemoveAnnotationItem(inputFile, annotationIndex);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditPdfApi.EditPdfRemoveAnnotationItem: " + e.Message );}}}}

That’s it! Our annotation is now gone. We have a ton more useful API functions like this that can save you all kinds of work. They cover everything from converting between file formats to editing documents and images.

--

--

Cloudmersive

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