將簽章要求新增至 XPS 檔
本主題描述如何將簽章要求新增至 XPS 檔。 如果使用者同意簽章意圖,簽章要求會提示使用者簽署檔。
在程式中使用下列程式碼範例之前,請先閱讀一般數位簽章程式設計 工作中的 免責聲明。
若要將簽章要求新增至 XPS 檔:
- 將 XPS 檔載入簽章管理員,如初始化簽章管理員 中所述 。
- 將簽章區塊新增至簽章管理員。
- 在新的簽章區塊中建立簽章要求。
- 設定簽章要求的屬性:
- 設定簽章意圖。
- 設定要求籤章的人員名稱(要求的簽署者)。
- 設定需要簽章的日期。
- 視需要設定其他簽章屬性。
下列程式碼範例說明如何將簽章要求新增至 XPS 檔。
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;
}
相關主題
-
用於本節
-
詳細資訊