Sign the digital signature using a private key and password.




void Sign(string path, string password)
void Sign(byte[] data, string password)
void Sign(Stream stream, string password)
void Sign(Stream stream, string password, Oid oid)
void Sign(X509Certificate2 cert, bool silent)
void Sign(X509Certificate2 cert, bool silent, Oid oid, X509IncludeOption? option)

[Visual Basic]
Sub Sign(path As String, password As String)
Sub Sign(data() As Byte, password As String)
Sub Sign(stream As Stream, password As String)
Sub Sign(stream As Stream, password As String, oid As Oid)
Sub Sign(cert As X509Certificate2, silent As Boolean)
Sub Sign(cert As X509Certificate2, silent As Boolean, oid As Oid, option As X509IncludeOption?)

Throws Exceptions may throw Exception()



Name Description
path The path to the PFX/PKCS #12 (.pfx or .p12) file used for signing.

The data for the PFX/PKCS #12 (.pfx or .p12) file used for signing.


The stream for the PFX/PKCS #12 (.pfx or .p12) file used for signing.

password The password used to authorize use of the private key.
oid The OID of the hash algorithm that should be used to create the digest. The default is SHA1 which is what will be used if null is passed.

The System.Security.Cryptography.X509Certificates.X509Certificate2 object for the PFX/PKCS #12 (.pfx or .p12) certificate used for signing.


Whether to suppress prompting the user to use the private key. While using the private keys of some certificates (such as those imported with the check box "Enable strong private key protected. You will be prompted every time the private key is used by an application if you enable this option." checked), a dialog box is displayed and must be closed if this parameter is false, and the signing fails if this parameter is true. For a non-interactive/unattended operation, this parameter should be set to true.

option The parts of the signing certificate chain which should be included in the signature. The default is WholeChain which is what will be used if null is passed.




Use this method to sign a signature field.

In order to sign a signature, you need to use your private key. To authorize the use of this key, you need to provide your password if you are not using a X509Certificate2 certificate.

Typically, this password protected private key is held in an PFX/PKCS #12 (.pfx or .p12) file. So to perform the signing operation, you provide a path to this file and a password to allow use of the private key.

Different digest algorithms may be used to create signatures. The default is SHA256 but you may also use SHA256, SHA384, SHA512, SHA256RSA, SHA384RSA and SHA512RSA.

Time-stamped signatures can be produced by using the service of a Time Stamping Authority (TSA). See TimestampServiceUrl.

If you are signing multiple signature fields in the same PDF document, you should call Commit manually after each signing operation.

If the file is not available, if the file is invalid or if the password is incorrect, then this function will throw an exception.




Read a document and sign a signature field embedded within that document. Before signing, we specify a location and a reason why the document is being digitally signed.

Doc theDoc = new Doc();
Signature theSig = (Signature)theDoc.Form["Signature"];
theSig.Location = "Washington";
theSig.Reason = "Schedule Agreed";
theSig.Sign(Server.MapPath("../Rez/JohnSmith.pfx"), "1234");

[Visual Basic]
Dim theDoc As Doc = New Doc()
Dim theSig As Signature = theDoc.Form("Signature")
theSig.Location = "Washington"
theSig.Reason = "Schedule Agreed"
theSig.Sign(Server.MapPath("../Rez/JohnSmith.pfx"), "1234")