Adding and Signing Empty Signature Fields with PDFSign
Requirements: Secure PDF
Introduction
In PDF signing workflows, documents often need to be signed by multiple parties. Empty signature fields allow a document creator to "reserve" designated areas for each party to sign, ensuring that the document maintains a clear structure and order as it moves through the signing process.
This article explains how to use the PDFSign component from Secure PDF to add empty signature fields to be signed later as well as sign existing signature fields in PDF documents.
Contents
Adding Empty Fields
In PDFSign, empty signature fields are added in the same way as regular signatures except for the fact that a signing certificate is not required. To create an empty signature field, simply set the SignatureType property to stEmptyField before calling the Sign method:
pdfsign.InputFile = "input.pdf";
pdfsign.OutputFile = "emptyfield.pdf";
pdfsign.SignatureType = PDFSignSignatureTypes.stEmptyField;
pdfsign.Sign();
Although the new empty signature field has not yet been officially signed, a new PDFSignature object will automatically be created and added to the Signatures collection.
Signing Empty Fields
The only additional step in configuring PDFSign to sign empty signature fields compared with creating regular signatures is to set the SignatureField property to the index of the field in the Signatures collection. This property instructs the component to place a signature into an existing field rather than carve out an entirely new field in the document. For example:
pdfsign.Reset();
pdfsign.InputFile = "emptyfield.pdf";
pdfsign.OutputFile = "signed.pdf";
pdfsign.Open();
int idx = -1;
// Find index of first empty signature field
for (int i = 0; i < pdfsign.Signatures.Count; i++)
{
if (pdfsign.Signatures[i].SignatureType == PDFSignatureTypes.stEmptyField)
{
idx = i;
break;
}
}
pdfsign.SigningCert = new Certificate(CertStoreTypes.cstPFXFile, "cert.pfx", "password", "*");
pdfsign.SignatureField = idx;
// Configure signature properties as desired
pdfsign.Sign();
pdfsign.Close();
We appreciate your feedback. If you have any questions, comments, or suggestions about this article please contact our support team at support@nsoftware.com.