Undo annotation modification

What is the proper way to undo a modification to an annotation? For example, say I change the color of a line drawn with the FreeHandCreate tool from red to blue. How do I undo that and change it back to red? Or say I erase some of that line with the eraser tool. How do I undo the effects of the eraser?

I can capture when an annotation is modified via the ToolManager.AnnotationModified event, but that event doesn’t tell me what of the annotation was changed or give me any reference to the annotation before it was changed.

I am using the Xamarin APIs.

You could export the single Annotation to a FDF file, using PDFDoc.FDFExtract. The FDF contains all the low level SDF information. You could keep multiple of these, for each undo step. And keep track of which annotation they belong too.

When you want to roll back, you would do a low level import, using SDFDoc.ImportObj to import from the FDF (which is a PDF) back to your PDF, and then swap the annotation index reference to the new one, using SDFDoc.Swap