0

下面是我如何发送文档以获取我需要在此附加文档上运行 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();

您能否建议我如何添加该代码..提前致谢。

4

1 回答 1

2

您使用了错误的代码模式。使用您的代码,您可以应用模板,也可以将文档添加到信封,但您将无法将模板应用到文档。要将模板应用于文档,您需要使用Composite Template。如果服务器模板和添加的文档中都存在锚字符串(自动放置),那么使用复合模板,您将用添加的文档替换服务器模板文档。一个例子如下。有一个带有锚字符串(自动放置)的文档,并且“”节点中的Server Template - 1afc0348-e853-4a0c-92db-06101168eb4dFileName -“ ”有一个新文档,需要从服务器模板应用自动放置锚字符串。下面的代码将展示如何使用复合模板来实现这一点。Added Document Agreementdocument

{
   "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"
}
于 2018-01-25T15:19:53.003 回答