如何在通过DocuSignApi发送的文档的最后一页上放置签名标签?

huangapple go评论52阅读模式
英文:

How to put sign here tab on last page of document sending via DocuSignApi?

问题

这是用于使用DocuSign Api构建多个动态文档的信封的代码。对我来说很好用,但主要问题是它将“在此处签名”选项卡放在每个文档的第一页。但我想将其放在每个文档的最后一页。在Laravel中,我该如何实现这一点?有人可以为我提供建议吗?

英文:

Here is my code for building envelope for multiple dynamic documents with DocuSign Api. It works fine for me but the main problem is it puts "sign here" tab on the first page of every documents. But, I want to put it on the last page of every documents. How can I achieve this in laravel? Can anyone suggests me for this?

private function buildEnvelope($envelopeFiles, $user): EnvelopeDefinition
    {
        $recipientEmail = $user->email;
        $recipientName = $user->first_name . " " . $user->last_name;

        // Create an array to store all CompositeTemplate objects
        $compositeTemplates = [];
        foreach ($envelopeFiles as $index => $documentPath) {
            $fileContent = file_get_contents($documentPath);
            $fileName = pathinfo($documentPath, PATHINFO_BASENAME);
            $fileExtension = pathinfo($documentPath, PATHINFO_EXTENSION);

            // Create a Document object for the current document
            $document = new Document([
                'document_base64' => base64_encode($fileContent),
                'name' => $fileName,
                'file_extension' => $fileExtension,
                'document_id' => $index + 1
            ]);

            // Create a SignHere tab for the current document
            $signHereTab = new SignHere([
                'document_id' => $index + 1,
                'page_number' => 1,
                'recipient_id' => '1',
                'tab_label' => 'Sign Here',
                'x_position' => '70',
                'y_position' => '780'
            ]);

            // Create a Tabs object for the current document with the SignHere tab
            $tabs = new Tabs([
                'sign_here_tabs' => [$signHereTab]
            ]);

            // Create a Signer object for the recipient with the Tabs object
            $recipient = new Signer([
                'email' => $recipientEmail,
                'name' => $recipientName,
                'recipient_id' => '1',
                'routing_order' => '1',
                'tabs' => $tabs
            ]);

            // Create an InlineTemplate object for the current document with the recipient
            $recipients = new Recipients(['signers' => [$recipient]]);
            $inlineTemplate = new InlineTemplate([
                'sequence' => $index + 1,
                'recipients' => $recipients
            ]);

            // Create a CompositeTemplate object for the current document with the Document 
            $compositeTemplate = new CompositeTemplate([
                'inline_templates' => [$inlineTemplate],
                'document' => $document
            ]);

            // Add the CompositeTemplate object to the array of CompositeTemplate objects
            $compositeTemplates[] = $compositeTemplate;
        }

        // Create the EnvelopeDefinition object with all the CompositeTemplate objects and other settings
        $envelopeDefinition = new EnvelopeDefinition([
            'composite_templates' => $compositeTemplates,
            'email_subject' => "Please sign the documents",
            'status' => "sent"
        ]);

        return $envelopeDefinition;
    }

答案1

得分: 1

这一行:

'page_number' => 1,

是需要更新的部分,但问题在于如果每个文档/信封的页面数量不固定,而且你不知道有多少页,你首先需要进行一次 API 调用来获取这个信息。如果你知道有4页,你可以将 "1" 替换为 "4",否则你需要进行3次 API 调用:

  1. 仅上传文档到 DocuSign,不包括标签/SignHere。
  2. 获取文档对象以便知道有多少页。
  3. 添加 SignHere 标签。

注意: 在使用 API 将文档发送到 DocuSign之前,DocuSign 无法告诉你文档有多少页。

英文:

This line:

'page_number' => 1,

Is what you need to update, but the problem is if every document/envelope has a variable number of pages, and you don't know how many, you'll have to first make an API call to find out. If you know it's 4 pages, you replace the "1" with "4", otherwise you have to make 3 API calls:

  1. Just to upload the documents to DocuSign, without the tabs/SignHere
  2. To get back the document object so you can know how many pages.
  3. To add just the SignHere tab

Note: DocuSign cannot tell you how many pages will a document be until you sent it over to DocuSign using the API.

huangapple
  • 本文由 发表于 2023年2月27日 13:21:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75577002.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定