Skip to content
ComPDF
Guides

Edit Annotations

The ComPDF React Native SDK provides APIs to modify annotation properties, allowing you to update the appearance and content of existing annotations. The following example demonstrates how to change an annotation’s color, opacity, and content:

tsx
const document = pdfReaderRef?.current?._pdfDocument;

const page = document.pageAtIndex(0);
const annotations = await page?.getAnnotations();
const annotation = annotations![0];

annotation.update({
  title: `Updated ${annotation.type} Annotation`,
  content: `This ${annotation.type} annotation has been updated.`,
  color: "#FF33AA",
  alpha: 180,
});

await document.updateAnnotation(annotation);

For a complete list of editable properties, refer to the definitions of the specific annotation classes, such as CPDFNoteAnnotation, CPDFMarkupAnnotation, and others.

In addition, the ComPDF SDK provides a built-in annotation properties panel. You can display the annotation properties editor by calling the following API:

tsx
await pdfReaderRef?.current?.showAnnotationPropertiesView(annotation);