How to read an image from the appearance stream of a stamp annotation?

I am trying to get an image which is stored in the appearance stream of
a stamp annotation. Could you supply some sample code to get this
annotation please? Any general annotation code would be great too.


You may want to take a look at 'Annot' sample project
( for an example
of how to traverse all annotations on the page.

To extract the image used in the stamp annotation appearance stream you
could use the following C# pseudo-code:

// The images in stamp annotations are stored separately as part of
// annotation objects (which are drawn in a separate layer on top of
page content).
// You can extract the annotation appearances by iterating through page
// as follows:
Page page = itr.Current();
int num_annots = page.GetNumAnnots();
ElementReader reader = ElementReader();
for (int i=0; i<num_annots; ++i) {
  Annot annot = page.GetAnnot(i);
  Console.WriteLine("Annot Type: {0:s}",
  Rect bbox = annot.GetRect();
  Console.WriteLine(" Position: {0:f}, {1:f}, {2:f}, {3:f}", bbox.x1,
bbox.y1, bbox.x2, bbox.y2);
  if (annot.GetType() == Annot.Type.e_Stamp)
       Obj app_stm = annot.GetAppearance();
       // then you can use Element reader to read annotation
       if (app_stm != null) {
          //... You may also need to recursively process form XObjects
          ProcessElement(reader); // See ElementReader sample project
          // an example of how to use implement this function