How do I create a digital signature annotation and set its appearance?

Q: I need a sample of how to create a signature and set its appearance
I will populate the signature data, but I need to create a signature
annotation and set its appearance (to a scanned image of a signature)

Can you provide me with a sample?
A: Sample code to create a digital signature and set its appearance:

Field sig = doc.FieldCreate("sig", Field.Type.e_signature);
pdftron.PDF.Annots.Widget a = pdftron.PDF.Annots.Widget.Create(sdfdoc,
new Rect(50, 550, 350, 600), sig); a.SetAppearance

static Obj CreateSignatureAppearance(PDFDoc doc)
    ElementBuilder b = new ElementBuilder();
    ElementWriter w = new ElementWriter();

    pdftron.PDF.Image img = pdftron.PDF.Image.Create(doc,
    int width = img.GetImageWidth();
    int height = img.GetImageHeight();
    Element img_element = b.CreateImage(img, 0, 0, width, height);

    Obj stm = w.End();

    // Set the bounding box
    stm.PutRect("BBox", 0, 0, width, height);
    stm.PutName("Subtype", "Form");


    return stm;

You can see a digital signature annotation when viewing the file in
Acrobat. In order to see the image you need to switch off 'Highlight
Fields' option in the upper right corner.

There is now an API on the new Annots.SignatureWidget class.