we are developing, with Java library from REST API, a procedure to sign multiple documents where the signature position is set using anchorString in signHereTabs for each signer (anchorString is a string inserted into the document to be signed); since we have documents with size greater than 25MB, we are using what has been reported in https://developers.docusign.com/esign-rest-api/guides/resource-limits , that is we create a draft envelope (status=created) and then we updates the envelope with the documents; the problem is that when we set the envelope with status = sent, the signer receives the email, open the link to DocuSign, but only the first document allow to access the anchorString. Is there any particular way to update the list of documents in the draft envelope ?
Thanks
...
// add a recipient to sign the document, identified by name and email we used above
int recipientId = 0;
List<Signer> signerList = new ArrayList<Signer>();
/* to fix the position where the signature has to be inserted */
int buyerIdx = 0;
int supplierIdx = 0;
for(DSSignerInfo signerInfo : signers) {
Tabs tabs = new Tabs();
Signer signer = new Signer();
signer.setEmail(signerInfo.getEmail());
signer.setName(signerInfo.getName());
signer.setRecipientId(String.valueOf(++recipientId));
signer.setRoutingOrder(String.valueOf(recipientId)); // sequential
signer.setRoleName("role unknown");
RecipientEmailNotification emailNotification = new RecipientEmailNotification();
emailNotification.setEmailBody("emailBody - "+signerInfo.getName());
emailNotification.setEmailSubject("emailSubject - "+signerInfo.getName());
emailNotification.setSupportedLanguage(signerInfo.getLanguage());
signer.setEmailNotification(emailNotification);
// create a signHere tab somewhere on the document for the signer to sign
// default unit of measurement is pixels, can be mms, cms, inches also
for(int documentId = 1; documentId <= documentFiles.size(); documentId++) {
SignHere signHere = new SignHere();
signHere.setDocumentId("" + documentId);
signHere.setPageNumber("1");
signHere.setRecipientId(String.valueOf(recipientId));
if(signerInfo.getRole().equalsIgnoreCase("buyer")) {
signHere.setAnchorString("BUYER_"+buyerIdx);
} else {
signHere.setAnchorString("SUPPLIER_"+supplierIdx);
}
signHere.setAnchorXOffset("10");
signHere.setAnchorYOffset("10");
tabs.addSignHereTabsItem(signHere);
}
signer.setTabs(tabs);
signerList.add(signer);
if(signerInfo.getRole().equalsIgnoreCase("buyer")) {
buyerIdx++;
} else {
supplierIdx++;
}
}
Recipients recipients = new Recipients();
recipients.setSigners(signerList);
envDef.setRecipients(recipients);
try {
String envelopeId = null;
EnvelopesApi envelopesApi = null;
// create a byte array that will hold our document bytes
int documentId = 1;
for(String documentFile : documentFiles) {
byte[] fileBytes = null;
try {
// read file
Path path = Paths.get(documentFile);
fileBytes = Files.readAllBytes(path);
} catch (IOException ioExcp) {
// handle error
System.out.println("Exception: " + ioExcp);
return null;
}
// add a document to the envelope
Document doc = new Document();
String base64Doc = Base64.getEncoder().encodeToString(fileBytes);
doc.setDocumentBase64(base64Doc);
String fileName = new File(documentFile).getName();
doc.setName(documentId+"_"+fileName);
doc.setFileExtension(fileName.lastIndexOf('.') > 0 ? fileName.substring(fileName.lastIndexOf('.') + 1) : "");
doc.setDocumentId("" + documentId++);
envDef.addDocumentsItem(doc);
if(envelopeId == null || envelopesApi == null) {
// To save as a draft set to "created" (for test purpose I create and envelope with only one file)
envDef.setStatus("created");
envelopesApi = new EnvelopesApi();
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
envelopeId = envelopeSummary.getEnvelopeId();
} else {
// the files after the 1st are updated in the draft envelope
envDef.setRecipients(recipients);
List<Document> tmpDocumentList = new ArrayList<Document>();
doc.setApplyAnchorTabs("true");
tmpDocumentList.add(doc);
envDef.setDocuments(tmpDocumentList);
EnvelopeDocumentsResult envelopeDocumentsResult = envelopesApi.updateDocuments(accountId, envelopeId, envDef);
}
}
Envelope envelope = envelopesApi.getEnvelope(accountId, envelopeId);
envelope.setStatus("sent");
envelope.setPurgeState(null);
EnvelopesApi.UpdateOptions uo = envelopesApi. new UpdateOptions();
uo.setAdvancedUpdate("true");
EnvelopeUpdateSummary envelopeUpdateSummary = envelopesApi.update(accountId, envelopeId, envelope, uo);
documentId = 1;
for(String documentFile : documentFiles) {
Tabs tabs = envelopesApi.getDocumentTabs(accountId, envelopeId, ""+documentId++);
System.out.println("CARLO Tabs 3, documentId "+(documentId - 1)+": "+tabs);
}
Thanks for your answer. More details: in the envelope we have more than one document; the size of each document is less than 25MB; the sum of the sizes of all the documents is more than 25MB. We can upload documents in envelope with status "created", but when the status is changed to "sent" and the signer goes into the signature page then it is not required to sign these documents; it seem that the signHereTabs is not set in the documents added while envelope status is "created".
If after having set envelope status = "sent" we execute the following code
documentId = 1;
for(String documentFile : documentFiles) {
Tabs tabs = envelopesApi.getDocumentTabs(accountId, envelopeId, ""+documentId++);
System.out.println("Tabs: documentId "+(documentId - 1)+": "+tabs);
}
we obtain
Tabs: documentId 1: class Tabs { ... signHereTabs: [class SignHere { anchorCaseSensitive: null anchorHorizontalAlignment: null anchorIgnoreIfNotPresent: null anchorMatchWholeWord: null anchorString: BUYER_0 anchorUnits: pixels anchorXOffset: 10 anchorYOffset: -10 conditionalParentLabel: null conditionalParentValue: null customTabId: null documentId: 1 errorDetails: null mergeField: null name: SignHere optional: false pageNumber: 1 recipientId: edb96dfd-9700-4328-ba45-825a1284b030 scaleValue: 1.0 stampType: signature stampTypeMetadata: null status: null tabId: e484087c-70c2-431c-9825-47605e1f44c2 tabLabel: Sign Here tabOrder: null templateLocked: null templateRequired: null tooltip: null xPosition: 123 yPosition: 297 }] ... } Tabs: documentId 2: class Tabs { ... signHereTabs: [] ... }
where documentId 1 has been uploaded when the envelope has been created (status="created"), and documentId 2 has been uploaded in a second step (both documentId 1 and 2 contain the anchorString: BUYER_0).