2017-01-20 4 views
0

Я использую Docusign php api. Я подписываю документ этим api. Все отлично . Но теперь мне нужны подписи получателей в нескольких местах. Я не знаю, сколько раз мне нужна подпись. Даже я не знаю позицию, где мне нужна подпись, я просто имею место в html-документе, и это # ​​\ b. Я должен поставить подпись вкладку, где это # ​​\ BDocusign single signer, но несколько подписей на документе

// create a new DocuSign configuration and assign host and header(s) 
    $config = new DocuSign\eSign\Configuration(); 
    $config->setHost($host); 
    $config->addDefaultHeader("X-DocuSign-Authentication", "{\"Username\":\"" . $username . "\",\"Password\":\"" . $password . "\",\"IntegratorKey\":\"" . $integrator_key . "\"}"); 
    ///////////////////////////////////////////////////////////////////////// 
    // STEP 1: Login() API 
    ///////////////////////////////////////////////////////////////////////// 
    // instantiate a new docusign api client 
    $apiClient = new DocuSign\eSign\ApiClient($config); 
    // we will first make the Login() call which exists in the AuthenticationApi... 
    $authenticationApi = new DocuSign\eSign\Api\AuthenticationApi($apiClient); 
    // optional login parameters 
    $options = new \DocuSign\eSign\Api\AuthenticationApi\LoginOptions(); 
    // call the login() API 
    $loginInformation = $authenticationApi->login($options); 
    // parse the login results 
    if(isset($loginInformation) && count($loginInformation) > 0) 
    { 
     // note: defaulting to first account found, user might be a 
     // member of multiple accounts 
     $loginAccount = $loginInformation->getLoginAccounts()[0]; 
     if(isset($loginInformation)) 
     { 
      $accountId = $loginAccount->getAccountId(); 
     } 
    } 
    if(empty($accountId)) 
    { 
     return false; 
    } 
    ///////////////////////////////////////////////////////////////////////// 
    // STEP 2: Create & Send Envelope (aka Signature Request) 
    ///////////////////////////////////////////////////////////////////////// 
    // set recipient information 

    // instantiate a new envelopeApi object 
    $envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($apiClient); 
    // Add a document to the envelope 
    $document = new DocuSign\eSign\Model\Document(); 
    $document->setDocumentBase64(base64_encode(file_get_contents($documentFileName))); 
    $document->setName($documentName); 
    $document->setDocumentId("1"); 
    // Create a |SignHere| tab somewhere on the document for the recipient to sign 
    $signHere = new \DocuSign\eSign\Model\SignHere(); 
    $signHere->setXPosition("20"); 
    $signHere->setYPosition("20"); 
    $signHere->setDocumentId("1"); 
    $signHere->setPageNumber("1"); 
    $signHere->setRecipientId("1"); 

    // add the signature tab to the envelope's list of tabs 
    $tabs = new DocuSign\eSign\Model\Tabs(); 
    $tabs->setSignHereTabs(array($signHere)); 
    // add a signer to the envelope 
    $signer = new \DocuSign\eSign\Model\Signer(); 
    $signer->setEmail($recipientEmail); 
    $signer->setName($recipientName); 
    $signer->setRecipientId("1"); 
    $signer->setClientUserId('12345'); 
    $signer->setTabs($tabs); 
    // Add a recipient to sign the document 
    $recipients = new DocuSign\eSign\Model\Recipients(); 
    $recipients->setSigners(array($signer)); 
    $envelop_definition = new DocuSign\eSign\Model\EnvelopeDefinition(); 
    $envelop_definition->setEmailSubject("Please sign this doc"); 
    // set envelope status to "sent" to immediately send the signature request 
    $envelop_definition->setStatus("sent"); 
    $envelop_definition->setRecipients($recipients); 
    $envelop_definition->setDocuments(array($document)); 
    // create and send the envelope! (aka signature request) 
    $envelop_summary = $envelopeApi->createEnvelope($accountId, $envelop_definition, null); 
    if($envelop_summary) 
    { 
     $document=json_decode($envelop_summary); 
     $envloped=$document->envelopeId; 
     // get the document url 
     $ReturnUrl=add_query_arg(array('action'=>'docusign_request','_uid'=>$formprocess,'_envelopid'=>$envloped),get_permalink()); 

     $viewrequest = new DocuSign\eSign\Model\RecipientViewRequest(); 
     $viewrequest->setUserName($recipientName); 
     $viewrequest->setEmail($recipientEmail); 
     $viewrequest->setRecipientId(1); 
     $viewrequest->setClientUserId('12345'); 
     $viewrequest->setAuthenticationMethod('email'); 
     $viewrequest->setReturnUrl($ReturnUrl); 
     $envelopview=$envelopeApi->createRecipientView($accountId,$document->envelopeId,$viewrequest); 
     $redirecturl=$envelopview->getUrl(); 
     wp_redirect($redirecturl); 
     // get the doc url 
    } 

ответ

0

Вы должны использовать вкладки DocuSign Якорь для этой цели

https://github.com/docusign/docusign-soap-sdk/wiki/Code-Walkthrough-_-Anchor-Tabs

Якорные Вкладки решение для этого. Поскольку вкладка Anchor работает, сопоставляя строку, которая присутствует в тексте документа, нам просто нужно будет изучить документ и посмотреть, есть ли подходящий бит текста. У многих контрактов есть что-то вроде «Знак здесь», напечатанный в документе, поэтому мы могли бы использовать это как текст привязки, а затем DocuSign разместил бы подпись подписи во всем документе, где он найдет текст «Sign Here».

// Create a |SignHere| tab somewhere on the document for the recipient to sign 
$signHere = new \DocuSign\eSign\Model\SignHere(); 
$signHere->setDocumentId("1"); 
$signHere->setPageNumber("1"); 
$signHere->setRecipientId("1"); 

    $signHere->AnchorTabItem->AnchorTabString = "#\b"; 
    $signHere->AnchorTabItem->Unit = "Pixels"; 
    $signHere->AnchorTabItem->XOffset = 50; 
    $signHere->AnchorTabItem->YOffset = 100; 
    $signHere->AnchorTabItem->IgnoreIfNotPresent = true; 
+0

Я не знаю, сколько раз мне нужна подпись, даже я не знаю, положение, в котором мне нужно вкладку подписи, я просто заполнители в HTML документ, и это # ​​\ b. Я должен поставить подпись, где находится # \ b – MKD

+0

не работает. напечатайте «Подпишите здесь» как есть. – MKD

+0

Вы преобразовали документ с текстом # \ b или что-то еще? Вы можете попробовать установить IgnoreIfNotPresent = false и посмотреть, вызывает ли это ошибку. Это означало бы, что текст анкера, который вы ищете, отсутствует в документе. –

Смежные вопросы