DigitalSignatureUtil Class
Provides methods for signing document.
Inheritance Hierarchy
SystemObject
  Aspose.WordsDigitalSignatureUtil

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.11
Syntax
public static class DigitalSignatureUtil
Methods
  NameDescription
Public methodStatic memberCode exampleLoadSignatures(Stream)
Loads digital signatures from document using stream.
Public methodStatic memberCode exampleLoadSignatures(String)
Loads digital signatures from document.
Public methodStatic memberCode exampleRemoveAllSignatures(Stream, Stream)
Removes all digital signatures from document in source stream and writes unsigned document to destination stream.

Output will be written to the start of stream and stream size will be updated with content length.

Public methodStatic memberCode exampleRemoveAllSignatures(String, String)
Removes all digital signatures from source file and writes unsigned file to destination file.
Public methodStatic memberCode exampleSign(Stream, Stream, CertificateHolder)
Signs source document using given CertificateHolder with digital signature and writes signed document to destination stream.

Document should be either Doc or Docx.

Output will be written to the start of stream and stream size will be updated with content length.

Public methodStatic memberCode exampleSign(String, String, CertificateHolder)
Signs source document using given CertificateHolder with digital signature and writes signed document to destination file.

Document should be either Doc or Docx.

Public methodStatic memberCode exampleSign(Stream, Stream, CertificateHolder, SignOptions)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination stream.

Document should be either Doc or Docx.

Output will be written to the start of stream and stream size will be updated with content length.

Public methodStatic memberCode exampleSign(String, String, CertificateHolder, SignOptions)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination file.

Document should be either Doc or Docx.

Remarks

Since digital signature works with file content rather than Document Object Model these methods are put into a separate class.

Supported formats are Doc and Docx.

Examples
Shows how to remove every signature from a document.
// Remove all signatures from the document using string parameters
Document doc = new Document(MyDir + "Document.DigitalSignature.docx");
string outFileName = ArtifactsDir + "Document.NoSignatures.FromString.docx";

DigitalSignatureUtil.RemoveAllSignatures(doc.OriginalFileName, outFileName);

// Remove all signatures from the document using stream parameters
using (Stream streamIn = new FileStream(MyDir + "Document.DigitalSignature.docx", FileMode.Open))
{
    using (Stream streamOut = new FileStream(ArtifactsDir + "Document.NoSignatures.FromStream.docx", FileMode.Create))
    {
        DigitalSignatureUtil.RemoveAllSignatures(streamIn, streamOut);
    } 
}
See Also