How to remove PDF annotations including comments in a document in C# .NET Framework

Cloudmersive
1 min readFeb 9, 2020

--

Removing PDF annotations in .NET Framework is a piece of cake with the help of an API, as you will soon see.

Installation is our first step, requiring this command to be entered into the console of Package Manager.

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

To proceed, we need to run our PDF file through EditPdfRemoveAllAnnotations, shown here:

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 EditPdfRemoveAllAnnotationsExample{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.try{// Remove all PDF annotations, including comments in the documentbyte[] result = apiInstance.EditPdfRemoveAllAnnotations(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling EditPdfApi.EditPdfRemoveAllAnnotations: " + e.Message );}}}}

Easy! Our document will be returned to us, sans annotations and comments. For more helpful API functions like this and how to use them, check out the rest of this tutorial series.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet