To delete an annotation on a layer, you can modify the example for adding annotations and include the Id (which is a GUID) of the annotation to be deleted.
public static Annotation DeleteAnnotationOnPage(Page page, int layer, string annotationId)
{
Annotation deleteAnnotationEntry = new Annotation()
{
Layer = new List<Layer>()
{
new Layer()
{
Id = layer,
Items = new List<EntryBase>()
{
new DeleteEntry()
{
Id = annotationId
}
}
}
}
};
Annotation postDeleteAnnotation = page.PostToAnnotationRelationForAnnotation(deleteAnnotationEntry);
return postDeleteAnnotation;
}
The annotation is obtained from the EntryBase object, as here:
Pages docSectionPages = docSection.PostToPagesBlockRelationForPages(qPagesBlock);
List<Page> pageCollection = docSectionPages.Page;
foreach (Page secPage in pageCollection)
{
Annotation pageAnnotation = secPage.GetAnnotationFromAnnotationRelation();
List<Layer> annotationLayers = pageAnnotation.Layer;
DWpageNumLayers = annotationLayers.Count;
for (int jindex = 0; jindex < DWpageNumLayers; jindex++)
{
List<EntryBase> layerBaseEntries = annotationLayers[jindex].Items;
foreach (EntryBase layerBaseEntry in layerBaseEntries)
{
anyAnnotationId = layerBaseEntry.Id;
// layers are 1-based
DeleteAnnotationOnPage(secPage, jindex + 1, anyAnnotationId);
}
}
}