This quick tutorial guides how to add signature in Word using C# by sharing configuration details, detailed steps, and a runnable sample code that uses the source Word document, a PKCS12 store and its password. You can set a number of properties before signing the document that is visible to the users for their reference. Once you insert electronic signature in Word using C#, it can be saved in any of the supported formats like DOCX, DOC, etc.
Steps to Add Signature in Word using C#
- Configure the development environment to add Aspose.Words using the NuGet package manager to sign documents
- Load the PFX certificate using the CertificateHolder class by providing the file path and password
- Set comments and signing time using the SignOptions object
- Load the source Word file using FileStream
- Sign the loaded document using the Sign method in the DigitalSignatureUtil class
- Load the signed document and verify the signature information
These steps describe the process to add digital signature in Word using C# by sharing all the required classes and methods. We need to load the certificate along with the password and then set a few properties like comments by the signing authority, signing date-time, signature line image, and provider id. Finally, we sign the document using the DigitalSignatureUtil class and save the document on disk however, the last step is optional where we have demonstrated the verification of the signature by loading the signed document back and displaying its information.
Code to Sign Word Documents using C#
This code demonstrates how to insert signature in Word using C# by using the DigitalSignatureUtil class. It supports many other features as well like removing all signatures from a Word file for modifying it. Similarly, the DigitalSignature class that is used to get the reference of the signature in the loaded document contains a number of properties like sign time, comments, subject name, and issuer name.
This tutorial has guided us to add signature to Word using C#. If you are interested in creating a Word file from scratch, refer to the article on how to create Word document in C#.