Digital Signature
Use the Wordize Signature for .NET module to work with the digital signature in the document.
You can also select document conversion module to work with the required formats. Please note that Wordize Signature for .NET currently only supports DOC, DOT, DOCX, DOTX, DOCM, ODT, OTT, and XPS formats.
A full list of conversion modules can be found on the Supported Document Formats page.
Wordize allows users to digitally sign documents, ensuring their authenticity and integrity. A digital signature verifies that the document has not been altered after signing and confirms the signer’s identity. This feature is essential for legal documents, contracts, and other sensitive files.
With Wordize Signature for .NET, you can:
- Sign documents programmatically
- Remove signatures when needed
- Work with cryptographic standards for secure signing
Sign a Document
To digitally sign a document, use an X.509 certificate and apply the signature using one of the Sign methods:
- Sign(string, string, CertificateHolder)
- Sign(string, string, CertificateHolder, SignOptions)
- Sign(Stream, Stream, CertificateHolder)
- Sign(Stream, Stream, CertificateHolder, SignOptions)
A CertificateHolder is a digital certificate that follows the internationally accepted X.509 PKI standard, ensuring the public key within the certificate is linked to the signer included inside the certificate.
You also can specify document signing options using the following properties of the SignOptions class:
- Comments – to add a comment to your sign
- SignTime – to add the date of signing
- DecryptionPassword – to add a password to decrypt the source document
- ProviderId – to specify the signature provider class ID
- XmlDsigLevel – to specify the digital signature level based on the XML-DSig standard
The following code example shows how to add a digital signature into a document using the Sign(string, string, CertificateHolder) method:
CertificateHolder holder = CertificateHolder.Create(@"C:\Temp\morzal.pfx", "wordize");
Signer.Sign(@"C:\Temp\in.docx", @"C:\Temp\out.docx", holder);
The following code example shows how to add a digital signature into a document, specifying sing options and using the Sign(string, string, CertificateHolder, SignOptions) method:
SignOptions signOptions = new SignOptions();
signOptions.Comments = "My Signature";
signOptions.SignTime = DateTime.Now;
CertificateHolder holder = CertificateHolder.Create(@"C:\Temp\morzal.pfx", "wordize");
Signer.Sign(@"C:\Temp\in.docx", @"C:\Temp\out.docx", holder, signOptions);
The following code example shows how to add a digital signature into a document using the Sign(Stream, Stream, CertificateHolder) method:
CertificateHolder holder=CertificateHolder.Create(@"C:\Temp\morzal.pfx", "wordize");
using (FileStream inputStream = File.OpenRead(@"C:\Temp\in.docx"))
{
using (FileStream outputStream = File.Create(@"C:\Temp\out.docx"))
{
Signer.Sign(inputStream, outputStream, holder);
}
}
The following code example shows how to add a digital signature into a document, specifying sing options and using the Sign(Stream, Stream, CertificateHolder, SignOptions) method:
SignOptions signOptions = new SignOptions();
signOptions.Comments = "My Signature";
signOptions.SignTime = DateTime.Now;
CertificateHolder holder=CertificateHolder.Create(@"C:\Temp\morzal.pfx", "wordize");
using (FileStream inputStream = File.OpenRead(@"C:\Temp\in.docx"))
{
using (FileStream outputStream = File.Create(@"C:\Temp\out.docx"))
{
Signer.Sign(inputStream, outputStream, holder);
}
}
Removing a Signature
If you need to remove digital signatures from a document, use one of the RemoveAllSignatures methods:
- RemoveAllSignatures(string, string)
- RemoveAllSignatures(Stream, Stream)
The following code example shows how to remove all digital signatures from a document using the RemoveAllSignatures(string, string) method:
Signer.RemoveAllSignatures(@"C:\Temp\in_signed.docx", @"C:\Temp\out_unsigned.docx");
The following code example shows how to remove all digital signatures from a document using the RemoveAllSignatures(Stream, Stream) method:
using (FileStream inputStream = File.OpenRead(@"C:\Temp\in_signed.docx"))
{
using (FileStream outputStream = File.Create(@"C:\Temp\out_unsigned.docx"))
{
Signer.RemoveAllSignatures(inputStream, outputStream);
}
}