Remove PDF annotations in MAUI
In addition to providing APIs for creating and editing annotations, we also offer an API for removing annotations. To remove annotations, use the IAnnotationManager.DeleteAnnotationsAsync()
method:
var annotations = await _annotationManager.GetAnnotationsOnPageAsync(0); var annotationIdToDelete = annotations[0].Id; await _annotationManager.DeleteAnnotationsAsync(annotationIdToDelete);
Following the optimistic UI approach, the changes will be instantly visible in the UI, but they aren’t persisted until the annotations are saved. This is done by saving them using JavaScript APIs. You can save them to external storage or embed them into a document. They can also be exported to Instant JSON using native APIs or XFDF by bridging JavaScript APIs.