Using 'pdftron.PDF.Stamper' to add & remove Headers, Footers, Watermarks

Q: In trying to implement something like was is described in the
following post (to selectively delete stamps

http://groups.google.com/group/pdfnet-sdk/t/6901c785e9a67bd1), but I
have been unsuccessful.

Seems even though I calling SetName on the 'private' dictionary entry
all stamps still get deleted. Basically my code looks like this.

Page page = doc.GetPage(pagenumber);
pdftron.SDF.Obj d = page.GetResourceDict();
for (pdftron.SDF.DictIterator itr = d.GetDictIterator();
itr.HasNext(); itr.Next()) {
    pdftron.SDF.Obj xobj = itr.Value();
    pdftron.SDF.Obj pdfTronPrivate = null;
    pdftron.SDF.Obj p = xobj.FindObj("PieceInfo");

if(p.FindObj("PDFTRON").FindObj("Private").GetName().Contains("Watermark"))
    {
       pdfTronPrivate = p.FindObj("PDFTRON").FindObj("Private");
      //logic to determine if stamp should be kept
      pdfTronPrivate.SetName("WatermarkCCG");
    }
}

Stamper.DeleteStamps(doc, new PageSet(1, doc.GetPageCount()));

Can you tell me what I am doing wrong, or if this is not possible?
-----------------------
A: It seems that DeleteStamps simply checks for PDFTRON entry in the
"PieceInfo" dictionary. This means that you can modify (i.e. rename)
this dictionary entry instead of the "PDFTRON / Private / Header". For
example:

Page page = doc.GetPage(pagenumber);
pdftron.SDF.Obj d = page.GetResourceDict();
for (pdftron.SDF.DictIterator itr = d.GetDictIterator();
itr.HasNext(); itr.Next()) {
    pdftron.SDF.Obj xobj = itr.Value();
    pdftron.SDF.Obj pdfTronPrivate = null;
    pdftron.SDF.Obj p = xobj.FindObj("PieceInfo");
    if (p != null) {
       p.Rename("PDFTRON", "FOO");
    }
}

It seems that you also need to rename any ‘Contents’ stream tagged
with PDFTRON to something else. For example:

Obj c = page.GetContents();
if (c!=null && c.IsArray()) {
      for (int i=0; i<c.Size(); ++i) {
          Obj o = c.GetAt(i);
          if (o.IsStream() && o.FindObj("PDFTRON")) {
             o.Rename("PDFTRON", "FOO");
          }
      }
}

So by renaming PDFTRON key in the content stream along with the form
xobject (i.e. "PieceInfo/PDFTRON"), you should be able to retain the
header stamping.