How do I set the border appearance for digital signature field?

Q: I have generated signature fields with the code below. I want to
have a border surrounding the signature field. My experiments with
SetBorderStyle and SetColor don't seem to work. How do I set the
border or appearance for digital signature field?

The code used to create signature field is as follows:

  // Create the 1'st signature field for the owner to sign
  Field Sig1 = doc.FieldCreate("Signature1", Field.Type.e_signature);
  Annot annSig1 = new Annot(Sig1.GetSDFObj());
  annSig1.SetBorderStyle(new Annot.BorderStyle(3));
  annSig1.SetColor(new ColorPt(0, 0, 1));
  Obj sig1Dict = Sig1.GetSDFObj();
  // Check for presence of the tool tip and save the tool tip text
  if (sig1Dict.FindObj("TU") == null)
      sig1Dict.PutString("TU", EoCData.Signers[0].Split('@')[0]);
  if (sig1Dict.Find("XSigner") == null)
      sig1Dict.PutString("XSigner", "[" + EoCData.Signers[0].Split('@')
[0] + "][" + EoCData.Signers[0] + "]");
  Annot sig1Annot = Annot.CreateWidget(sdfdoc, new Rect(170, 705, 418,
675), Sig1);

  // Create the 2'nd signature field for the approver to sign

  doc.Save(PdfFile, Doc.SaveOptions.e_linearized);
A: The problem is that the annotation appearance is missing and
Acrobat is not auto-generating appearance for signatures. There are
couple of options.

One option is to set the "NeedAppearances" in AcroForms dictionary:

doc.GetAcroForm().PutBool("NeedAppearances", true);

This will force viewer application to auto-generate new appearance
streams every time the document is opened.

In case you prefer to generate the appearance yourself (which is
probably the best option), you can use the approach illustrated in
InteractiveForms sample project. For example,

// C# pseudo code (for a relevant code snippets please see
// helper functions in InteractiveForms sample:

Obj CreateMyAppearance(PDFDoc doc, pdftron.PDF.Rect r)
// Create a button appearance stream
ElementBuilder build;
ElementWriter writer;

// Draw the annotation border
Element element = build.CreateRect(r.x1+1, r.y1+1, r.x2-1, r.y2-1);

element.GetGState().SetStrokeColor(new ColorPt(1, 0, 0));
Obj stm = writer.End();

// Set the clip
stm.PutRect("BBox", r.x1, r.y1, r.x2, r.y2);
return stm;

To set the appearance use :

my_annot.SetAppearance(CreateMyAppearance(doc, my_annot.GetRect()));