In my application, I have a package of PDFs that I combine and send to DocuSign. This works perfectly using SignHere and Initial here AnchorTags; however, I have now need to include certain PDF's that require user input fields (such as a W-9 form). I have tried multiple ways of creating the template, without success. I've been able to get DocuSign to recognize all of the PDF form fields (in the templates UI) but I haven't been able to get those to the user.
I have two significant issues:
First, I can't get DocuSign to include both my custom file and the template I created with input fields in the recipient's document.
I'm able to get the W-9 template to the recipient (but not the custom file) but without any input fields or tags.
I have pasted my code below
// create a new envelope to manage the signature request
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.setEmailSubject(documentName);
// add a document to the envelope
Document doc = new Document();
doc.setDocumentBase64(Base64.getEncoder().encodeToString(fileBytes)); //custom file
doc.setName(documentName);
//this is the objectid of the ElectronicDocument
doc.setDocumentId(ElectronicDocumentId);
List<Document> docs = new ArrayList<Document>();
docs.add(doc);
envDef.setDocuments(docs);
Signer signer = new Signer();
signer.setEmail(primarySignerEmail);
signer.setName(primarySignerName);
signer.setRecipientId(primarySignerId);
signer.setAccessCode(primaryAuthCode);
signer.setRoleName("PrimaryTenant"); //so we attach them to w9template
////create tab code not included
//create the tabs and assign to signer
Tabs tabs = new Tabs();
tabs.setSignHereTabs(signHereTabs);
tabs.setInitialHereTabs(initialHereTabs);
tabs.setDateSignedTabs(dateSignedTabs);
signer.setTabs(tabs);
Blob blob = w9Template.getFileBlob();
int blobLength;
try {
blobLength = (int) blob.length();
w9Bytes = blob.getBytes(1, blobLength);
blob.free();
} catch (SQLException e) {
logger.warn(e);
}
if (w9Bytes != null){
//create compositTemplate for w-9
CompositeTemplate compositeTemplate = new CompositeTemplate();
InlineTemplate inlineTemplate = new InlineTemplate();
inlineTemplate.setSequence("2");
//create w-9 document
Document docw9 = new Document();
docw9.setDocumentBase64(Base64.getEncoder().encodeToString(w9Bytes));
docw9.setName("W-9");
docw9.setDocumentId(ElectronicDocumentId);
docw9.transformPdfFields("true");
compositeTemplate.document(docw9);
inlineTemplate.setRecipients(new Recipients());
inlineTemplate.getRecipients().setSigners(new ArrayList<Signer>());
inlineTemplate.getRecipients().getSigners().add(signer);
List<InlineTemplate> inlineTemplateList = new ArrayList<InlineTemplate>();
inlineTemplateList.add(inlineTemplate);
compositeTemplate.inlineTemplates(inlineTemplateList);
List<CompositeTemplate> compositeTemplateList = new ArrayList<CompositeTemplate>();
compositeTemplateList.add(compositeTemplate);
envDef.setCompositeTemplates(compositeTemplateList);
}
// add recipient(s) to the envelope
envDef.setRecipients(new Recipients());
envDef.getRecipients().setSigners(new ArrayList<Signer>());
envDef.getRecipients().getSigners().add(signer);
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
envDef.setStatus("sent");
try
{
// instantiate a new EnvelopesApi object
EnvelopesApi envelopesApi = new EnvelopesApi();
// call the createEnvelope() API
// use the |accountId| we retrieved through authenticate() function to create the Envelope
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
logger.debug("EnvelopeSummary: " + envelopeSummary);
}
catch (com.docusign.esign.client.ApiException ex)
{
}
In advance, I thank you for your effort. I have been trying to figure this out out all day.