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");
}
}