How do I flatten PDF annotaions and fields?

Q: How do I flatten PDF annotaions and fields using PDFNet SDK (http://
www.pdftron.com/pdfnet)?
--------
A: You can flatten any annotation type using Annot.Flatten() method.
Please note that annotations must be flattened in the reverse order
(since Annot.Flatten() method removes the object from the annotation
array in the page dictionary).

For example:

// In C++:
PDFNet::Initialize();
try {
  PDFDoc doc("in.pdf");
  doc.InitSecurityHandler();
  for (PageIterator pitr = doc.GetPageIterator(); pitr.HasNext();
pitr.Next()) {
    Page page = pitr.Current();
    for (int j=page.GetNumAnnots()-1; j>=0; --j) {
      Annot ann = page.GetAnnot(j);
      ann.Flatten(page);
    }
  }

  doc.Save("out.pdf", 0, 0);
}
catch(Common::Exception& e) {
  cout << e << endl;
  ret = 1;
}

// In VB.NET

Imports System
Imports pdftron
Imports pdftron.Common
Imports pdftron.SDF
Imports pdftron.PDF

Module Module1
  Sub Main()
    PDFNet.Initialize()
    Try
      Dim doc As PDFDoc = New PDFDoc("in.pdf")
      doc.InitSecurityHandler()

      For i As Integer = 1 To doc.GetPageCount()
        Dim pg As Page = doc.GetPage(i)
        For j As Integer = pg.GetNumAnnots() - 1 To 0 Step -1
          Dim ann As Annot = pg.GetAnnot(j)
          ann.Flatten(pg)
        Next
      Next
      doc.Save("out.pdf", 0)
      doc.Close()
    Catch ex As PDFNetException
      Console.WriteLine(ex.Message)
    Catch ex As Exception
      MsgBox(ex.Message)
    End Try
  End Sub
End Module