I am working on a Laravel application where I have integrated DocuSign for sending documents for electronic signatures. I followed the official DocuSign API documentation to set up JWT authentication and successfully send documents. However, when I send a document for signing, the signature field does not appear on the document.
As I mentioned, I successfully send the documents and the code for building the envelope is the following:
public function buildEnvelope(Request $request): EnvelopeDefinition
{
$fileContent = $request->file('formFile')->get();
$fileName = $request->file('formFile')->getClientOriginalName();
$fileExtension = $request->file('formFile')->getClientOriginalExtension();
$recipientEmail = $request['email'];
$recipientName = $request['name'];
$document = new Document([
'document_id' => "1",
'document_base64' => base64_encode($fileContent),
'file_extension' => $fileExtension,
'name' => $fileName
]);
$sign_here_tab = new SignHere([
'anchor_string' => "**signature**",
'page_number' => "1",
'anchor_units' => "pixels",
'anchor_x_offset' => "100",
'anchor_y_offset' => "300"
]);
$tabs = new Tabs([
'sign_here_tabs' => [$sign_here_tab]
]);
$signer = new Signer([
'email' => $recipientEmail,
'name' => $recipientName,
'recipient_id' => "1",
'tabs' => $tabs
]);
$recipients = new Recipients([
'signers' => [$signer]
]);
$inlineTemplate = new InlineTemplate([
'recipients' => $recipients,
'sequence' => "1"
]);
$compositeTemplate = new CompositeTemplate([
'composite_template_id' => "1",
'document' => $document,
'inline_templates' => [$inlineTemplate]
]);
return new EnvelopeDefinition([
'composite_templates' => [$compositeTemplate],
'email_subject' => "Please sign",
'status' => "sent"
]);
}
I have specified the page number, some random coordinates, anchor string, and anchor units and expected that on page 1 somwhere I'd see the text signature
You may want to double check that the string **signature**
actually appears in your document. The SignHere tab will be placed in the document where that text appears, but that text needs to be in your document already. The coordinates, anchor_x_offset
and anchor_y_offset
, specify how the tab will be offset from the anchor string. If you're placing a tab with anchor strings you don't need to include the page number property.
If you'd prefer to use coordinates to place your tab you can use the xPosition and yPosition properties. You can see this blog post for examples of how the code looks different if you use anchor tabs vs coordinates.