Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This topic describes how to add a signature request to an XPS document. A signature request prompts a user to sign a document if he or she agrees with the signature intent.
Before using the following code examples in your program, read the disclaimer in Common Digital Signature Programming Tasks.
To add a signature request to an XPS Document:
- Load the XPS document into a signature manager, as described in Initialize the Signature Manager.
- Add a signature block to the signature manager.
- Create a signature request in the new signature block.
- Set the properties of the signature request:
- Set the signature intent.
- Set the name of the person whose signature is requested (the requested signer).
- Set the date the signature is required.
- Set other signature properties as required.
The following code example illustrates how to add a signature request to an XPS document.
HRESULT
AddSignatureRequestToDocument (
__in IXpsSignatureManager *signatureManager,
__in LPCWSTR reasonForSignatureRequest,
__in LPCWSTR nameOfRequestedSigner,
__in LPCWSTR requestSignByDate
)
{
HRESULT hr = S_OK;
IXpsSignatureBlock *signatureDefinition = NULL;
IXpsSignatureRequest *signatureRequest = NULL;
// Create a new signature block and get a pointer to it
hr = signatureManager->AddSignatureBlock (NULL, 0, &signatureDefinition);
if (SUCCEEDED(hr)) {
// Create a new signature request to use for this signature block
hr = signatureDefinition->CreateRequest(NULL, &signatureRequest);
}
if (SUCCEEDED(hr)) {
// Initialize the properties of the signature request
// Set the string that describes the purpose of the signature
// to the person who will sign the document.
hr = signatureRequest->SetIntent(reasonForSignatureRequest);
}
if (SUCCEEDED(hr)) {
// Set the name of the person whose signature is requested.
hr = signatureRequest->SetRequestedSigner(nameOfRequestedSigner);
}
if (SUCCEEDED(hr)) {
// Set the date that the person should sign the document.
// The person is requested to sign the document on or before
// the date specified in this field. Refer to the help text
// for the correct format of this string.
hr = signatureRequest->SetRequestSignByDate(requestSignByDate);
}
if (NULL != signatureDefinition) signatureDefinition->Release();
if (NULL != signatureRequest) signatureRequest->Release();
return hr;
}
Related topics
Used in This Section
IXpsSignatureBlock::CreateRequest
IXpsSignatureManager::AddSignatureBlock
IXpsSignatureRequest::SetIntent
IXpsSignatureRequest::SetRequestedSigner
IXpsSignatureRequest::SetRequestSignByDate
For More Information