On this page
Guides
Edit Annotations
The steps to edit an annotation are as follows:
- Obtain the page object where the annotation needs to be edited.
- Access the list of annotations on that page.
- Locate the desired annotation in the annotation list and convert it.
- Set the properties to the annotation object.
- Update the annotation appearance to display it on the document.
This example shows how to edit annotations:
java
CPDFPage page = document.pageAtIndex(0);
List<CPDFAnnotation> annotations = page.getAnnotations();
if (annotations != null && annotations.size() > 0) {
CPDFAnnotation annotation = annotations.get(0);
if (annotation.getType() == CPDFAnnotation.Type.FREETEXT) {
CPDFFreetextAnnotation freetextAnnotation = (CPDFFreetextAnnotation) annotation;
CPDFTextAttribute textAttribute = new CPDFTextAttribute("fontname", 20, Color.YELLOW.getRGB());
freetextAnnotation.setFreetextDa(textAttribute);
freetextAnnotation.updateAp();
}
}