DigitalSignatureUtilSign Method (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.
Namespace:
Aspose.Words
Assembly:
Aspose.Words (in Aspose.Words.dll) Version: 20.3
Syntaxpublic static void Sign(
Stream srcStream,
Stream dstStream,
CertificateHolder certHolder,
SignOptions signOptions
)
Public Shared Sub Sign (
srcStream As Stream,
dstStream As Stream,
certHolder As CertificateHolder,
signOptions As SignOptions
)
public:
static void Sign(
Stream^ srcStream,
Stream^ dstStream,
CertificateHolder^ certHolder,
SignOptions^ signOptions
)
static member Sign :
srcStream : Stream *
dstStream : Stream *
certHolder : CertificateHolder *
signOptions : SignOptions -> unit
Parameters
- srcStream
- Type: System.IOStream
The stream which contains the document to sign. - dstStream
- Type: System.IOStream
The stream that signed document will be written to. - certHolder
- Type: Aspose.WordsCertificateHolder
CertificateHolder object with certificate that used to sign file.
The certificate in holder MUST contain private keys and have the X509KeyStorageFlags.Exportable flag set. - signOptions
- Type: Aspose.WordsSignOptions
SignOptions object with various signing options.
ExamplesShows how to sign documents using certificate holder and sign options.
CertificateHolder certificateHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
SignOptions signOptions = new SignOptions { Comments = "My comment", SignTime = DateTime.Now };
using (Stream streamIn = new FileStream(MyDir + "Digitally signed.docx", FileMode.Open))
{
using (Stream streamOut = new FileStream(ArtifactsDir + "DigitalSignatureUtil.SignDocument.docx", FileMode.OpenOrCreate))
{
DigitalSignatureUtil.Sign(streamIn, streamOut, certificateHolder, signOptions);
}
}
See Also