大网数据广告活动
打印与设备

Add a Signature Request to an XPS Document

· 52CE 我爱测

This topic describes how to add a signature request to an XPS document.

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:

  1. Load the XPS document into a signature manager, as described in Initialize the Signature Manager.
  2. Add a signature block to the signature manager.
  3. Create a signature request in the new signature block.
  4. Set the properties of the signature request:
    1. Set the signature intent.
    2. Set the name of the person whose signature is requested (the requested signer).
    3. Set the date the signature is required.
    4. 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

IXpsSignatureBlock::CreateRequest

IXpsSignatureManager

IXpsSignatureManager::AddSignatureBlock

IXpsSignatureRequest

IXpsSignatureRequest::SetIntent

IXpsSignatureRequest::SetRequestedSigner

IXpsSignatureRequest::SetRequestSignByDate

For More Information

XPS Digital Signature API Errors

XPS Document Errors

XML Paper Specification

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。