How to set the a Signature to have an image and text?

Question:
I am adding Digital Signatures to a PDF, and I want the appearance to be an image with vector (scalable) text over top. How can I do that?

Answer:
The following code will set the appearance of any annotation with your image and your text over top.

static void SetAnnotationAppearance(PDFDoc doc, Page page, Annot annot, string imagePath, string text)
{
using(PDFDoc tempPdfDoc = new PDFDoc())
{
pdftron.PDF.Convert.ToPdf(tempPdfDoc, imagePath); // this call takes care of image DPI and image rotation
pdftron.PDF.Page tempPage = tempPdfDoc.GetPage(1);
using (Stamper stamper = new Stamper(Stamper.SizeType.e_relative_scale, 0.9, 0.9))
{
// set your font and color here if you like
stamper.SetAlignment(Stamper.HorizontalAlignment.e_horizontal_center, Stamper.VerticalAlignment.e_vertical_center);
stamper.StampText(tempPdfDoc, text, new PageSet(1));
// page 1 now has our appearance
// now make annotation and stamp back on the temp page.
stamper.SetAsAnnotation(true);
stamper.StampPage(tempPdfDoc, tempPage, new PageSet(1));
}
Annot tempStamp = tempPdfDoc.GetPage(1).GetAnnot(0);
Obj tempAp = tempStamp.GetAppearance();
// now we need to import annotation appearance and resources (font and image) to the target document
// once the using statement ends all the temporary objects will be released
Obj importedAp = doc.GetSDFDoc().ImportObj(tempAp, true);
annot.SetAppearance(importedAp);
}
}