AUGUST 3, 2015 in WinForms with 622 views and 143 downloads

(No Ratings Yet)

Creates a Pdf document containing a digital signature.

Built for Visual Studio 2005, 2008, 2010

Built for .NET 2.0

To add a signature to a C1Pdf document, you need to create and configure a PdfSignature object, than add it to the document using the AddField method.

For example:

// create and configure PdfSignature object
PdfSignature signature = new PdfSignature();
signature.Reason = "Demo";
signature.Certificate = _certificate as X509Certificate2;
signature.Handler = SignatureHandler.PPKLite;
signature.Visibility = FieldVisibility.Visible;
signature.BorderWidth = FieldBorderWidth.Medium;
signature.BorderColor = Color.Blue;
signature.BackColor = Color.White;
signature.Text = "Signature Field";
signature.Font = new Font("Tahoma", 14, FontStyle.Italic | FontStyle.Bold);

// add the signature to the document
_c1pdf.AddField(signature, new RectangleF(100, rc.Height - 100, 200, 50));

The code above assigns a Certificate to the signature. The Certificate is responsible for ensuring the identity of the sender.

The Certificate property is of type X509Certificate2, a class defined in the .NET System.dll (System.Security.Cryptography.X509Certificates namespace) and documented here:


Instantiating the certificate can be done as follows:

X509Certificate2 _certificate;
_certificate = new X509Certificate2(
X509KeyStorageFlags.PersistKeySet | X509KeyStorageFlags.MachineKeySet);

The certificateFileName parameter identifies an X509 certificate file issued to the document author (for details, please see http://en.wikipedia.org/wiki/X.509).

The signature.Handler property in the first code block determines the signature mode. C1Pdf supports two modes:

The "PPKMS" mode authenticates using a hash code instead of the actual file data. This mode is faster but less secure.

The "PPKLite" mode authenticates using the actual file data. It is slower but more secure.