Signing PDF Form using signature field

Hello,

I have the same requirement.

I have a simple PDF with form fields. Some of these fields are of SignatureField type.
I have a X509Certificate2 (I can convert it to pfx is needed).

How to put the digital signature INSIDE the SignatureField?
I found a lot of examples that only show how to create a Rect somewhere in the PDF doc and put the signature there. How can we put the contents sent to this Rect in the SignatureField?

Thank you,

Fernando

@fmag

Once you have a PDF with a signature field, you can sign it using the name of signature fields. For example:

Document doc = new Document();
doc.Pages.Add();
SignatureField field = new SignatureField(doc.Pages[1], new Rectangle(10, 800, 100, 700));
field.PartialName = "MySignField";
field.Border = new Border(field);
field.Contents = "Signature Field for John Doe";
field.Border.Width = 5;
doc.Form.Add(field);
doc.Save(dataDir + "SignatureField_out.pdf");

string file = dataDir + "SignatureField_out.pdf";

Document pdfDocument = new Document(file);

var pkcs7 = new Aspose.Pdf.Forms.PKCS7(dataDir + "mykey2.pfx", "aa");
pkcs7.ShowProperties = true;
using(var signature = new Facades.PdfFileSignature(pdfDocument))
{
 signature.Sign("MySignField", "MyReason", "SigContact", "SigLocation", pkcs7);
 //signature.Sign(1, true, new System.Drawing.Rectangle(300, 100, 400, 200), pkcs7);
 signature.Save(dataDir + "1stoutput.pdf");
}