以下是我如何发送签名文档,我需要在此附加文档上运行AutoPlace,但我无法使其工作。此代码正在运行,但未放置我在此模板中设置的自动程序。
$client = new DocuSign\Rest\Client([
'username' => config("docusign.DOCUSIGN_USERNAME"),
'password' => config("docusign.DOCUSIGN_PASSWORD"),
'integrator_key' => config("docusign.DOCUSIGN_INTEGRATOR_KEY"),
]);
$templateRole = $client->templateRole([
'email' => <email>,
'name' => <name>,
'role_name' => 'Client',
]);
$envelopeDefinition = $client->envelopeDefinition([
'status' => 'sent',
'email_subject' => 'Signature Required On Your Order ',
'template_id' => '<docusign template id>',
'template_roles' => [
$templateRole,
],
]);
$doc = Storage::disk('local')->url('mypdf.pdf');
$envelopeOptions = $client->envelopes->createEnvelopeOptions([
'documents' => [
'documentBase64' => base64_encode($doc),
'name' => 'mypdf.pdf',
],
]);
$envelopeSummary = $client->envelopes->createEnvelope($envelopeDefinition, $envelopeOptions);
print_R($envelopeSummary);
die();
您能否建议我如何添加该代码..提前感谢。
答案 0 :(得分:2)
您使用的是错误的代码模式。使用您的代码,您可以应用模板,也可以将文档添加到信封中,但无法将模板应用于文档。要将模板应用于文档,您需要使用Composite Template。如果服务器模板和添加的文档中都存在锚字符串(autoplace),则使用复合模板,您将使用添加的文档替换服务器模板文档。一个例子如下。 Added Document Agreement
有一个包含anchorstring(autoplace)和FileName - &#34; document
&#34;的文档。在&#34; {
"compositeTemplates": [
{
"document": {
"documentBase64": "<Base64>",
"documentId": "1",
"fileExtension": "pdf",
"name": "Added Document Agreement"
},
"inlineTemplates": [
{
"recipients": {
"signers": [
{
"email": "email@gmail.com",
"name": "John Doe",
"recipientId": "1",
"roleName": "InternalSigner",
"routingOrder": "1"
}
]
},
"sequence": "2"
}
],
"serverTemplates": [
{
"sequence": "1",
"templateId": "1afc0348-e853-4a0c-92db-06101168eb4d"
}
]
}
],
"status": "sent"
}
&#34; node有新文档,需要从服务器模板中应用autoplace锚点字符串。下面的代码将展示如何使用复合模板实现此目的。
const original = {"data":[["Dic",0,0,165,0],["Ene",0,0,200,0],["Ene",150,0,0,0],["Ene",150,20,10,500]]}
const tmp = original.data.reduce((a,c)=>{
a[c[0]] = (a[c[0]] || [c[0],0,0,0,0]).map((el,i)=> i ? el + c[i] :el);
return a;
}, {});
original.data = Object.keys(tmp).map(key => tmp[key]);
console.log(JSON.stringify(original))