Account


Earned badges

Achievement: Latest Unlocked

Topic Started

This user has not created any forum posts.

Replies Created

Reply to: Add extract anchor to a new document on an existing package

0 votes
Hi Guillaume! Thanks for being patient. The ability to set the anchor fields when creating the document is available in the REST API, however, we don't have it in the SDK. We're going to update the SDK to have this functionality by August 22nd. In the meantime, we have this method we put together (not thoroughly tested but it's working) if you'd like to plug that in to use for now. You can add it to the ESignLiveSDK class.
public String createDocumentWithBinariesAndFields(String packageId, ESignLiveAPIObjects.Document document, Map documentMap)
    {
        Blob multipartFormData;

        String secondHeader = '--' + BOUNDARY + '\nContent-Disposition: form-data; name="payload"';

        String footer = '--' + BOUNDARY + '--';             

        String secondHeaderEncoded = ESignLiveDocumentUtilities.encodeString(secondHeader);

        List encodedStrings = ESignLiveDocumentUtilities.encodeDocuments(documentMap,BOUNDARY,'file');

        String fileNamesJSON = '';

        for(String fileName : documentMap.keySet())
        {              
            fileNamesJSON = fileNamesJSON +'{ "name":"'+fileName+'" }' + ',';
        }
        
        String headerPlusBodyEncoded = encodedStrings[0];
        String footerEncoded = encodedStrings[1];
        
        String documentJSON = JSON.serialize(document);
        documentJSON = ESignLiveJSONHelper.prepareOutboundJSON(documentJSON);        

        String documentJSONEncoded = ESignLiveDocumentUtilities.encodeContent(documentJSON);

        multipartFormData = EncodingUtil.base64Decode(headerPlusBodyEncoded+secondHeaderEncoded+documentJSONEncoded+footerEncoded);

        String packageIdResponse = helper.createDocumentsWithBinaries(packageId, multipartFormData);
        return packageIdResponse;
    }
You'll need to build the Document object that will contain your anchor fields and you'll pass this in as an additional argument. At a minimum, your document should look something like this (serialized):
{
    "approvals": [
        {
            "fields": [
                {
                    "extract": false,
                    "extractAnchor": {
                        "anchorPoint": "TOPRIGHT",
                        "characterIndex": 0,
                        "height": 28,
                        "index": 0,
                        "leftOffset": 4,
                        "text": "Signature:",
                        "topOffset": -18,
                        "width": 200
                    },
                    "left": 0,
                    "subtype": "FULLNAME",
                    "top": 0,
                    "type": "SIGNATURE"
                }
            ],
            "role": "RobMartinez"
        }
    ],
    "name": "sampleTextExtract"
}
Let me know if you have any questions. Thanks! Rob Martinez

Subscriptions

Topics Replies Freshness Views Users
Is there an example somewhere showing how to set up delegate access with the APEX SDK? KB
1 8 years ago 103
Profile picture for user robmtz
First off, this is a very welcome addition to the integration options available.
2 8 years ago 93
Profile picture for user robmtz

Code Share

This user has not submitted any code shares.

Subscriptions Release Notes

This user is not subscribed to any release notes.