Skip to content
Guides

Delete Annotations

The steps to delete an annotation are as follows:

  1. Obtain the page object where the annotation needs to be deleted.

  2. Access the list of annotations on that page.

  3. Locate the desired annotation in the annotation list.

  4. Delete the identified annotation.

This example shows how to delete annotations:

java
// Retrieve the page object for annotating.
CPDFPage page = document.pageAtIndex(0);
// Retrieve the list of annotations for the page.
List<CPDFAnnotation> annotations = page.getAnnotations();
if (annotations != null && annotations.size() > 0) {
  // Locate the desired annotation in the list and remove it.
  page.deleteAnnotation(annotations.get(0));
}
kotlin
// Retrieve the page object for annotating.
val page = document.pageAtIndex(i)
// Retrieve the list of annotations for the page.
val annotations = page.annotations
if (annotations != null && annotations.size > 0) {
  // Locate the desired annotation in the list and remove it.
  page.deleteAnnotation(annotations[0])
}