0

I just created my developer account with DocuSign and apparently I need to know if I can use an HTML template for the documents that I need to attach to an envelope. I'm planning to use the REST API for this. But I would like to know if it's possible, all I can see from your documentations are PDFs and the template generators.

My goal is to generate the template(HTML) on the fly from my application and send that as a template to the API.

Any help would be really appreciated.

Thanks in advance.

Kenneth P.
  • 1,797
  • 3
  • 21
  • 31
  • What do you mean by "HTML template"? DocuSign Templates are server side objects that exist in your account, they contain documents, recipients, tabs, and other info. If you download the template definition (using the Classic UI) you'll see that it's XML format. Having said all that, your app can generate documents on the fly if that's what you mean and create envelopes in real time with those documents and data etc – Ergin Jun 24 '16 at 22:07
  • Per your example below, yes you can send HTML content into DocuSign and have it be honored best effort - please keep in mind that your content will be converted to a PDF. The conversion and support of various HTML properties does have a limit (from my own past experience), though the bulk of standard HTML components should be supported. – Luis Jun 27 '16 at 17:26
  • yup thanks, thats all I wanted able to pass an HTML template and covert it to pdf. – Kenneth P. Jun 28 '16 at 07:42

1 Answers1

1

Finally, I was able to achieve this using the PHP SDK. If you guys are interested to know here is how.

// set recipient information
$recipientName = "";
$recipientEmail = "";

// configure the document we want signed
$documentFileName = "/../document.html";
$documentName = "document.html";

// instantiate a new envelopeApi object
$envelopeApi = new DocuSign\eSign\Api\EnvelopesApi($this->getApiClient());

// Add a document to the envelope
$document = new DocuSign\eSign\Model\Document();
$document->setDocumentBase64(base64_encode(file_get_contents(__DIR__ . $documentFileName)));
$document->setName($documentName);
$document->setFileExtension('html');
$document->setDocumentId("2");

// Create a |SignHere| tab somewhere on the document for the recipient to sign
$signHere = new \DocuSign\eSign\Model\SignHere();
$signHere->setXPosition("100");
$signHere->setYPosition("100");
$signHere->setDocumentId("2");
$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->setTabs($tabs);
$signer->setClientUserId("1234");  // must set this to embed the recipient!

// 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("[DocuSign PHP SDK] - 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);
echo "$envelop_summary\n";

After I dig deeper on their documentation. Here is the source.

Kenneth P.
  • 1,797
  • 3
  • 21
  • 31