Reputation: 89
I want to add DocuSign signature tag dynamically in some specific section of my base64 custom pdf template which created from our web application where user can just click on tag to upload his/her signature not drag and drop his/her signature on specified section.
This is my code sample:
<?php
$pdfurl = 'assets/pdf/test-doc-docusign.pdf';
$docname = basename($pdfurl);
$pdfcontent = file_get_contents($pdfurl);
$base64content = base64_encode($pdfcontent);
$envelopjson = array();
$envelopjson['documents'] = array();
$envelopjson['documents'][0]['documentBase64'] = $base64content;
$envelopjson['documents'][0]['documentId'] = 57577;
$envelopjson['documents'][0]['fileExtension'] = "pdf";
$envelopjson['documents'][0]['name'] = $docname;
$envelopjson['emailSubject'] = "Please Sign";
$envelopjson['recipients'] = array();
$envelopjson['recipients']['signers'] = array();
$envelopjson['recipients']['signers'][0]['name'] = "user full name";
$envelopjson['recipients']['signers'][0]['email'] = "user email";
$envelopjson['recipients']['signers'][0]['recipientId'] = "458585";
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'] = array();
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['xPosition'] = 500;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['yPosition'] = 500;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['documentId'] = $trnx_id;
$envelopjson['templateRoles'][0]['tabs']['signHereTabs'][0]['signHere']['pageNumber'] = 1;
$envelopjson['status'] = "sent";
$requestjson = json_encode($envelopjson);
$envelopeinfo = MakeAPICall("POST","v2.1/accounts/".$docusign_account_id."/envelopes",$requestjson,$access_token);
How to solve the issue?
Upvotes: 1
Views: 787
Reputation: 14015
The templateRoles
objects are used to assign recipients to roles of the templates. If the tabs are not coming from the template, you cannot use this object to add tabs.
Instead, you have to make another API call to add the tabs. See code example showing how to update tabs in a template which include PHP code as well.
Alternatively, and the best practice, is to use composite templates, that give you the most flexibility in adding templates, documents, and tabs all in one API call.
Upvotes: 0
Reputation: 49114
Is your question how to have your application dynamically add DocuSign signing fields (tags) at various places in your documents?
There are several techniques available, especially when you have control over the software that is producing the documents.
For the following techniques, let's say that we ultimately want four tags: a sign here and date signed tag for signers 1 and 2.
You can include text in your document that is later used to place fields that use the auto place feature. See the anchorString property.
There are several tricks that may be of help for your use case:
In your source document, you can color the anchor text white (so it won't be visible). This way you can use anchor text such as "signer-1-sign-here" and a tab will be created for every instance of that string. (You do need to program a SignHere tab that looks for your anchorString "signer-1-sign-here".)
You can include anchor text more than once (even in different documents in the same envelope) and the tab will be created at each location.
If you don't include the anchor text, this is not an error. So you can have anchor text such as "signer-1-optional-initials" and if it is in the document an initials tab will be placed, otherwise nothing will happen. (This assumes that you program an initials tab that looks for that anchor string.)
An alternative is to use the smart sections feature and create your document as an HTML document with the tabs included in the HTML.
Upvotes: 1