Edytuj

Udostępnij za pośrednictwem


XpsSignatureDefinition Class

Definition

Represents an XpsDocument digital signature.

public ref class XpsSignatureDefinition
public class XpsSignatureDefinition
type XpsSignatureDefinition = class
Public Class XpsSignatureDefinition
Inheritance
XpsSignatureDefinition

Examples

The following example shows how to create and set the properties of an XpsSignatureDefinition.


private void SignatureDefinitionCommandHandler(object sender, RoutedEventArgs e)
{
    SignatureDefinition sigDefDialog = new SignatureDefinition();
    if (sigDefDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
    {
        XpsSignatureDefinition signatureDefinition = new XpsSignatureDefinition();
        signatureDefinition.RequestedSigner = sigDefDialog.RequestedSigner.Text;
        signatureDefinition.Intent = sigDefDialog.Intent.Text;
        signatureDefinition.SigningLocale = sigDefDialog.SigningLocale.Text;
        try
        {
            signatureDefinition.SignBy = DateTime.Parse(sigDefDialog.SignBy.Text);
        }
        catch (FormatException)
        {
        }
        signatureDefinition.SpotId = Guid.NewGuid();
        IXpsFixedDocumentSequenceReader docSeq = _xpsDocument.FixedDocumentSequenceReader; //_xpsDocument is type System.Windows.Xps.Packaging.XpsDocument
        IXpsFixedDocumentReader doc = docSeq.FixedDocuments[0];
        doc.AddSignatureDefinition(signatureDefinition);
        doc.CommitSignatureDefinition();
        InitializeSignatureDisplay();
    }
}

Private Sub SignatureDefinitionCommandHandler(sender As Object, e As RoutedEventArgs)
    Using sigDefDialog As New SignatureDefinition()
        If sigDefDialog.ShowDialog() = System.Windows.Forms.DialogResult.OK Then
            Dim signatureDefinition As New XpsSignatureDefinition With {
                .RequestedSigner = sigDefDialog.RequestedSigner.Text,
                .Intent = sigDefDialog.Intent.Text,
                .SigningLocale = sigDefDialog.SigningLocale.Text
            }
            Try
                signatureDefinition.SignBy = Date.Parse(sigDefDialog.SignBy.Text)
            Catch e1 As FormatException
            End Try
            signatureDefinition.SpotId = Guid.NewGuid()
            Dim docSeq As IXpsFixedDocumentSequenceReader = _xpsDocument.FixedDocumentSequenceReader '_xpsDocument is type System.Windows.Xps.Packaging.XpsDocument
            Dim doc As IXpsFixedDocumentReader = docSeq.FixedDocuments(0)
            doc.AddSignatureDefinition(signatureDefinition)
            doc.CommitSignatureDefinition()
            InitializeSignatureDisplay()
        End If
    End Using
End Sub

Remarks

For more information about signature definitions in XPS packages, see Chapter 10 in the XML Paper Specification (XPS).

For information about Package digital signatures, see Digital Signing Framework of the Open Packaging Conventions.

For information about XPS, see the XML Paper Specification (XPS).

Constructors

XpsSignatureDefinition()

Initializes a new instance of the XpsSignatureDefinition class.

Properties

Culture

Gets or sets the CultureInfo of the signature.

HasBeenModified

Gets or sets a value that indicates whether unwritten property changes exist for the XpsSignatureDefinition class and must be written to the package's stream.

Intent

Gets or sets the string value of the signature intention agreement that the signer is signing against.

RequestedSigner

Gets or sets the identity of the person who is requested to sign (or has signed) the package.

SignBy

Gets or sets the date and time by which the requested signer must sign the parts of the specified document.

SigningLocale

Gets or sets the legal jurisdiction where the package is signed.

SpotId

Gets or sets a unique identifier for this XpsSignatureDefinition.

SpotLocation

Gets or sets the location that specifies where to display the visible digital signature in an XML Paper Specification (XPS) document.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also