Signer.Sign
Sign(Stream, Stream, CertificateHolder)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination stream.
Supported formats are: Doc, Dot, Docx, Dotx, Docm, Odt, Ott, Xps.
Output will be written to the start of stream and stream size will be updated with content length.
public static void Sign(Stream srcStream, Stream dstStream, CertificateHolder certHolder)
| Parameter | Type | Description |
|---|---|---|
| srcStream | Stream | The stream which contains the document to sign. |
| dstStream | Stream | The stream that signed document will be written to. |
| certHolder | CertificateHolder | CertificateHolder object with certificate that used to sign file. The certificate in holder MUST contain private keys and have the X509KeyStorageFlags.Exportable flag set. |
See Also
- class CertificateHolder
- class Signer
- namespace Wordize.DigitalSignatures
- assembly Wordize
Sign(Stream, Stream, CertificateHolder, SignOptions)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination stream.
Supported formats are: Doc, Dot, Docx, Dotx, Docm, Odt, Ott, Xps.
Output will be written to the start of stream and stream size will be updated with content length.
public static void Sign(Stream srcStream, Stream dstStream, CertificateHolder certHolder,
SignOptions signOptions)
| Parameter | Type | Description |
|---|---|---|
| srcStream | Stream | The stream which contains the document to sign. |
| dstStream | Stream | The stream that signed document will be written to. |
| certHolder | CertificateHolder | 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 | SignOptions | SignOptions object with various signing options. |
Examples
Demonstrates how to sign document using streams.
CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
using (Stream input = File.OpenRead(MyDir + "Simple.docx"))
using (Stream output = File.Create(ArtifactsDir + "Signed.docx"))
{
Signer.Sign(input, output, certHolder);
}
See Also
- class CertificateHolder
- class SignOptions
- class Signer
- namespace Wordize.DigitalSignatures
- assembly Wordize
Sign(string, string, CertificateHolder)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination file.
Supported formats are: Doc, Dot, Docx, Dotx, Docm, Dotm, Odt, Ott, Xps.
public static void Sign(string srcFileName, string dstFileName, CertificateHolder certHolder)
| Parameter | Type | Description |
|---|---|---|
| srcFileName | String | The file name of the document to sign. |
| dstFileName | String | The file name of the signed document output. |
| certHolder | CertificateHolder | CertificateHolder object with certificate that used to sign file. The certificate in holder MUST contain private keys and have the X509KeyStorageFlags.Exportable flag set. |
See Also
- class CertificateHolder
- class Signer
- namespace Wordize.DigitalSignatures
- assembly Wordize
Sign(string, string, CertificateHolder, SignOptions)
Signs source document using given CertificateHolder and SignOptions with digital signature and writes signed document to destination file.
Supported formats are: Doc, Dot, Docx, Dotx, Docm, Dotm, Odt, Ott, Xps.
public static void Sign(string srcFileName, string dstFileName, CertificateHolder certHolder,
SignOptions signOptions)
| Parameter | Type | Description |
|---|---|---|
| srcFileName | String | The file name of the document to sign. |
| dstFileName | String | The file name of the signed document output. |
| certHolder | CertificateHolder | 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 | SignOptions | SignOptions object with various signing options. |
Examples
Demonstrates how to sign document.
CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
SignOptions signOptions = new SignOptions();
signOptions.Comments = "Test Signing";
signOptions.SignTime = DateTime.Now;
Signer.Sign(MyDir + "Simple.docx", ArtifactsDir + "Signed.docx", certHolder, signOptions);
Demonstrates how to sign document using Fluent API.
CertificateHolder certHolder = CertificateHolder.Create(MyDir + "morzal.pfx", "aw");
SignerContext context = new SignerContext();
context.CertificateHolder = certHolder;
context.SignOptions = new SignOptions() { XmlDsigLevel = XmlDsigLevel.XAdEsEpes };
Signer.Create(context)
.From(MyDir + "Simple.docx")
.To(ArtifactsDir + "Signed.docx")
.Execute();
See Also
- class CertificateHolder
- class SignOptions
- class Signer
- namespace Wordize.DigitalSignatures
- assembly Wordize