How can I flatten (merge with page) a non widget annotation (e.g. a stamp annotation)?

Q: I have a pdf document that has an image on the upper left hand
corner that is an annotation (a stamp annotation). I'm trying to add
content (barcode and some text) but the annotation's box covers up my
content (under the logo there is white space that is part of the
annotation). My question, is there a way to flatten that annotation
(it looks like it's a stamp on acrobat) as well as all other
annotations on the page?
A: The problem is that in PDF annotations are not part of the page
content, so they always float on top of the page. Also FlattenFields()
is used to flatten only widget annotations (i.e. form fields) .

There simplest way to solve the problem is to add the image as part of
the page content stream instead of using the stamp annotation. If this
is not possible and you can't modify original PDFs, you can also use
PDFNet API to flatten the stamp. You can do this by copying the
content from the annotation appearance stream to the target page.
Something along the following lines:

if (annot.GetType() == Annot.Type.e_Stamp) {
  Obj app_stm = annot.GetAppearance();
  if (app_stm != null) {
       ElementReader reader = new ElementReader();

       ElementWriter writer = new ElementWriter();

       Element element;
       while ((element = reader.Next()) != null) {
         //... You may also need to recursively process form
         // ProcessElement() in ElementReader and ImageExtract samples
for examples

After merging the content of the annotation with the page, you should
delete the annotation using page.AnnotRemove(annot).

You may also want to look for "How can I associate an image with a
form field" in the forum.

The better approach, when using more recent versions of the PDFNet SDK, is to use PDFDoc.FlattenAnnotations(). For more information, see