SignOptions

SignOptions class

Allows to specify options for document signing.

To learn more, visit the Work with Digital Signatures documentation article.

public class SignOptions

Constructors

NameDescription
SignOptions()The default constructor.

Properties

NameDescription
Comments { get; set; }Specifies comments on the digital signature. Default value is empty string(Empty).
DecryptionPassword { get; set; }The password to decrypt source document. Default value is empty string (Empty).
ProviderId { get; set; }Specifies the class ID of the signature provider. Default value is Empty (all zeroes) Guid.
SignatureLineId { get; set; }Signature line identifier. Default value is Empty (all zeroes) Guid.
SignatureLineImage { get; set; }The image that will be shown in associated SignatureLine. Default value is null.
SignTime { get; set; }The date of signing. Default value is current time (Now)
XmlDsigLevel { get; set; }Specifies the level of a digital signature based on XML-DSig standard. The default value is XmlDSig.

Examples

Shows how to digitally sign documents.

// Create an X.509 certificate from a PKCS#12 store, which should contain a private key.
CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");

// Create a comment and date which will be applied with our new digital signature.
SignOptions signOptions = new SignOptions
{
    Comments = "My comment", 
    SignTime = DateTime.Now
};

// Take an unsigned document from the local file system via a file stream,
// then create a signed copy of it determined by the filename of the output file stream.
using (Stream streamIn = new FileStream(MyDir + "Document.docx", FileMode.Open))
{
    using (Stream streamOut = new FileStream(ArtifactsDir + "DigitalSignatureUtil.SignDocument.docx", FileMode.OpenOrCreate))
    {
        DigitalSignatureUtil.Sign(streamIn, streamOut, certificateHolder, signOptions);
    }
}

See Also