How do I create or process existing digital signature annotations?


How do I create or process digital signature annotations using PDFNet?
The process of creating digital signature annotations is similar to
the one used to create other types of widgets (e.g. see
InteractiveForms sample project). For example:

// Assuming C# pseudocode ----------
Obj sig_dict = pdfdoc.CreateIndirectDict();
... fill our signature dictionary...
... for more information, please see Table 8.102 in PDF Reference

// Create a signature field.
Field sig = pdfdoc.FieldCreate("MySig", Field.Type.e_signature,

// Create a signature annotation
Annot sig_annot = Annot.CreateWidget(pdfdoc, new Rect(64, 356, 120,
410), sig);

// Add the signature annotation to an existing page...

CreateSignatureAppearance is a utility function used to create
signature appearance (e.g. a scanned signature image). It may look
along the following lines:

static Obj CreateButtonAppearance(PDFDoc doc) {
  ElementBuilder build = new ElementBuilder();
  ElementWriter writer = new ElementWriter();

  Image img = Image.Create(doc, "my_signature.png");
  int w=img.GetImageWidth(), h=img.GetImageHeight();
  Element img_element = build.CreateImage(img, 0, 0, w, h);

   Obj stm = writer.End();

   // Set the bounding box
   stm.Put("BBox", Rect.CreateSDFRect(0, 0, w, h));
   stm.Put("Subtype", Obj.CreateName("Form"));
   return stm;

Similarly, digital signatures annotations can be accessed like other
widgets (e.g. using pdfdoc.FieldFind()/FieldBeign()/FieldEnd()).

If the field has e_signature type, you can access its Cos/SDF
dictionary using GetSDFObj() method. For example,

field = pdfdoc.FieldFind("MySig");
pdftron.SDF.Obj form_dict = field.GetSDFObj(); // get signature value
DictIterator itr = form_dict.Find("V");
if (itr != form_dict.End()) {
  Obj dig_sig = itr.Value();
  // Access any key/value pair...
  // See Section 8.7 'Digital Signatures' in PDF
  // Reference Manual.
  itr = dig_sig.Find("SubFilter");
  if (itr != dig_sig.DictEnd()) {
  // ...
  itr = dig_sig.Find("XSigner"); // get a custom property
  if (itr != dig_sig.End()) {
    dig_sig.Put("XSigner", Obj.CreateString(""));
  // ...

Or to traverse all digital signatures in the document:

FieldIterator itr = doc.FieldBegin();
FieldIterator end = doc.FieldEnd();
for( ; itr != end; itr.Next()){
  Field field = itr.Current();
  Console.WriteLine("Field name: {0}", field.GetName());
  Field.FieldType type = field.GetType();
  if (type == Field.FieldType.e_signature) {
  Obj field_dict = field.GetSDFObj();
      // Perform COS/SDF read/write/edit operations on the signature.