How to Remove Annotation from PDF using Java

PDF documents are not editable and annotations are used to elaborate the content. So, we will create the step-by-step process to programmatically remove annotation from PDF using Java in this tutorial. In addition, we will develop a working example to show you the implementation to remove annotation in Java. Below you can find the steps and sample code to delete the annotation from documents.

Steps to Remove Annotation from PDF using Java

  1. Install GroupDocs.Annotation for Java from the Maven repository for removing the annotation
  2. Import the essential classes for deleting annotation from PDF document
  3. Create an instance of the Annotator class and pass the source PDF file to its constructor
  4. Initialize SaveOptions class and set AnnotationTypes = AnnotationType.None
  5. Finally, call the save method of the Annotator class and pass the resultant document path along with the SaveOptions object to it

The above points can be easily used to delete annotation from PDF using Java capability. First of all, install the required library and reference the necessary classes for removing annotation. In the next step, load the source PDF file by initializing the Annotator class and initiating SaveOptions class. Then, set setAnnotationTypes and call the save method of the Annotator class to store the resultant file on the disk.

Code to Remove Annotation from PDF using Java

We have created the capability to remove annotation using Java to demonstrate the working of the feature. We have consumed a few API calls and written three-four lines of code for removing annotation. You can run this code on operating systems including MS Windows, Linux, and Mac OS.

We have discussed the detailed instructions for removing annotation in Java from PDF documents and developed an example for it. We had recently published an article on adding link annotation to PDF documents in Java, have a look at how to Add Link Annotation using Java guide for more information.

 English