How do I get all the annotation comments so I can get them as plain text

Q:

How do I get all the annotation comments so I can get them as plain text for emailing.

A:

PageIterator itr = doc.GetPageIterator(); for (; itr.HasNext(); itr.Next()) { Page page = itr.Current(); int num_annots = page.GetNumAnnots(); for (int i = 0; i < num_annots; ++i) { Annot annot = page.GetAnnot(i); if (annot.IsValid() == false) continue; if (annot.GetType() == Annot.Type.e_Popup) continue; string contents = annot.GetContents(); if (contents.IsEmpty()) continue; // at this point you have an annotation with comments on it } }