添加签名字段 DocuSign

Add signature field DocuSign

我正在使用 curl PHP 方法创建一个 DocuSign 信封。如何使用 PHP 向我的 pdf 文档添加签名字段?

$headers = array(   
     'Content-Type: application/json',
    'Authorization: Bearer '.$access_token->access_token
    );

$content_bytes = file_get_contents($_SERVER['DOCUMENT_ROOT'] .'/public/demo_documents/'.$docfile);
$doc3_b64 = base64_encode($content_bytes);

$document = array (
  'documents' => 
  array (
    0 => 
    array (
      'documentBase64' => $doc3_b64,
      'documentId' => 1,
      'fileExtension' => 'pdf',      
      'name' => 'test '.$data['signer_name'],
      "transformPdfFields"=> true
    ),
  ),
  'emailSubject' => 'Test '.$data['signer_name'],
  'recipients' => 
  array (
    'signers' => 
    array (
      0 => 
      array (
        'email' => $data['signer_email'],//signer email Here
        'name' => $data['signer_name'],//signer Name Here
        'recipientId' => '1',
      ),
    ),

  ),
  'status' => 'sent',
  
);
$url = "https://demo.docusign.net/restapi/v2.1/accounts/$account_id/envelopes";


curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,json_encode($document));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$envelopes = json_decode(curl_exec($ch));

Here you go:

# Create the signer recipient model
$signer = new Signer([ # The signer
    'email' => $args['signer_email'], 'name' => $args['signer_name'],
    'recipient_id' => "1", 'routing_order' => "1"
]);

# Create a sign_here tab (field on the document)
$sign_here = new SignHere([ # DocuSign SignHere field/tab
    'anchor_string' => '/sn1/', 'anchor_units' => 'pixels',
    'anchor_y_offset' => '10', 'anchor_x_offset' => '20'
]);

# Add the tabs model (including the sign_here tab) to the signer
# The Tabs object wants arrays of the different field/tab types
$signer->settabs(new Tabs(['sign_here_tabs' => [$sign_here]]));

# Next, create the top level envelope definition and populate it.
$envelope_definition = new EnvelopeDefinition([
    'email_subject' => "Please sign this document sent from the PHP SDK",
    'documents' => [$document],
    # The Recipients object wants arrays for each recipient type
    'recipients' => new Recipients(['signers' => [$signer]]),
    'status' => "sent" # requests that the envelope be created and sent.
]);