The digital signature is a trustworthy scheme for verifying the authenticity of your documents. Digital signatures are often used to implement electronic signatures. In this article, you will learn how to electronically sign PDF and Word documents with digital certificates using C#.

.NET API for Digital Signatures and Certificates

For signing documents with the digital certificate, I will be using GroupDocs.Signature for .NET API in the C# examples of this article. In addition to the signing of PDF documents, this API supports digital signatures for word-processing documents and spreadsheet formats.

Download the DLLs or MSI installer from the downloads section or install the API in your .NET application via NuGet.

PM> Install-Package GroupDocs.Signature

Sign PDF with Digital Certificate in C#

After setting up the environment, you are few lines away from the successful signing of your documents. Follow the following steps to get your document signed with the available digital certificate using C#.

  • Initialize Signature object with the document to sign.
  • Initialize DigitalSignOptions object with the certificate file.
  • Set required sign options such as password, and position.
  • Call Sign method to sign the document with the digital certificate.

The following code example signs the PDF documents with the certificate in C#.

Sign with Digital Signature using custom Appearance in C#

The digital signature can be customized to have different presentations. For the personalized appearance, the following options can be customized using the PdfDigitalSignatureAppearance class.

  • Background
  • Contact Info
  • Date signed at
  • Digital signed
  • Location
  • Reason
  • Font Family
  • Font Size

Further, you can alter following properties:

  • Height
  • Width
  • Border Style
  • Show on All Pages or Not
Sign PDF with Digital Certificate

Signed PDF document with digital certificate using GroupDocs.Signature for .NET in C#

In the following example, I am using almost all of the above-mentioned properties. This example customizes the appearance of the digital signature in a PDF document using C#.

Sign Word Docs with Digital Certificate in C#

Similarly, you can sign Word documents using the certificate. Just provide the right document when you start with initializing the Signature object.

  • Initialize Signature object with the Word document to sign.
  • Initialize DigitalSignOptions object with the certificate file.
  • Set sign options such as password, and position.
  • Sign the document with the digital certificate using the Sign method.

The example signs the Word documents using the certificate in C#.

Conclusion

In this article, you have learned to electronically sign PDF and Word documents with the digital certificate using C#. Further, you can easily customize the appearance of the signature. Now you can try building your own .NET application for signing PDF and Word documents with digital certificates having a custom appearance in C#.

See Also