Hattabitos | Posts: 24

Text anchor full example

0 votes
I have a client who is using REST API to create package. She is getting error 400 when using text anchor.
{
	"name": "TEST2 32.pdf",
	"index": 0,
	"approvals": [{
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Dealer Signature",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 16,
				"leftOffset": 10,
				"topOffset": -28
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Dealer"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Dealer Signature",
				"index": 1,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 16,
				"leftOffset": 10,
				"topOffset": -28
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Dealer"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signed for and on behalf of Dealer\/Supplier",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "BOTTOMLEFT",
				"characterIndex": 1,
				"leftOffset": -5,
				"topOffset": 3
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Dealer"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Customer Signature(s)",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 200,
				"topOffset": -10
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer0"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature of Customer(s)",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "BOTTOMLEFT",
				"characterIndex": 0,
				"leftOffset": 0,
				"topOffset": 10
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer0"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature of Indemnifier",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 110,
				"topOffset": 5
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer0"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature(s) of Customer(s)",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 50,
				"topOffset": 20
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer0"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Customer Signature(s)",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 395,
				"topOffset": -10
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer1"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature of Customer(s)",
				"index": 1,
				"width": 150,
				"height": 40,
				"anchorPoint": "BOTTOMLEFT",
				"characterIndex": 0,
				"leftOffset": 0,
				"topOffset": 10
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer1"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature of Indemnifier",
				"index": 1,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 110,
				"topOffset": 5
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer1"
	}, {
		"fields": [{
			"type": "SIGNATURE",
			"width": 200,
			"height": 50,
			"extract": false,
			"extractAnchor": {
				"text": "Signature(s) of Customer(s)",
				"index": 0,
				"width": 150,
				"height": 40,
				"anchorPoint": "TOPRIGHT",
				"characterIndex": 1,
				"leftOffset": 245,
				"topOffset": 20
			},
			"left": 0,
			"subtype": "FULLNAME",
			"top": 0
		}],
		"role": "Signer1"
	}],
	"extract": true
}
Can we please send the client a full code that includes: package create, add signers, add document, add signature fields using text anchor?

harishaidary | Posts: 1812

Reply to: Text anchor full example

0 votes
Hey Ahmad, Here is a sample code on how to do all of the above in one single request. The code is written in C#, but your client should be able to figure out from the code all the appropriate headers to make her request in any technology:
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;

    public class CreateAndSendPackage
    {
        public static void Main(string[] args)
        {

            string apiKey = "your_api_key";
            string url = "https://sandbox.esignlive.com/api";

            string jsonString = "{ \"roles\":[ { \"id\":\"Dealer\", \"type\":\"SIGNER\", \"signers\":[ { \"firstName\":\"John\", \"lastName\":\"Smith\", \"email\":\"john.smith@example.com\" }], \"name\":\"\" }, { \"id\":\"Signer0\", \"type\":\"SIGNER\", \"signers\":[ { \"firstName\":\"SIGNER_FIRST_NAME\", \"lastName\":\"SIGNER_LAST_NAME\", \"email\":\"signer.email@example.com\" }], \"name\":\"\" }, { \"id\":\"Signer1\", \"type\":\"SIGNER\", \"signers\":[ { \"firstName\":\"test\", \"lastName\":\"test\", \"email\":\"test@example.com\" }], \"name\":\"\" }], \"documents\":[ { \"name\": \"TEST2 32.pdf\", \"index\": 0, \"approvals\": [{ \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Dealer Signature\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 16, \"leftOffset\": 10, \"topOffset\": -28 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Dealer\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Dealer Signature\", \"index\": 1, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 16, \"leftOffset\": 10, \"topOffset\": -28 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Dealer\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signed for and on behalf of Dealer\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"BOTTOMLEFT\", \"characterIndex\": 1, \"leftOffset\": -5, \"topOffset\": 3 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Dealer\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Customer Signature(s)\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 200, \"topOffset\": -10 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer0\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature of Customer(s)\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"BOTTOMLEFT\", \"characterIndex\": 0, \"leftOffset\": 0, \"topOffset\": 10 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer0\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature of Indemnifier\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 110, \"topOffset\": 5 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer0\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature(s) of Customer(s)\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 50, \"topOffset\": 20 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer0\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Customer Signature(s)\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 395, \"topOffset\": -10 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer1\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature of Customer(s)\", \"index\": 1, \"width\": 150, \"height\": 40, \"anchorPoint\": \"BOTTOMLEFT\", \"characterIndex\": 0, \"leftOffset\": 0, \"topOffset\": 10 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer1\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature of Indemnifier\", \"index\": 1, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 110, \"topOffset\": 5 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer1\" }, { \"fields\": [{ \"type\": \"SIGNATURE\", \"width\": 200, \"height\": 50, \"extract\": false, \"extractAnchor\": { \"text\": \"Signature(s) of Customer(s)\", \"index\": 0, \"width\": 150, \"height\": 40, \"anchorPoint\": \"TOPRIGHT\", \"characterIndex\": 1, \"leftOffset\": 245, \"topOffset\": 20 }, \"left\": 0, \"subtype\": \"FULLNAME\", \"top\": 0 }], \"role\": \"Signer1\" }], \"extract\": true }], \"name\": \"Test Package REST\", \"type\":\"PACKAGE\", \"language\":\"en\", \"emailMessage\":\"\", \"description\":\"New Package\", \"autoComplete\":true, \"status\":\"DRAFT\" }";
            StringContent jsonContent = new StringContent(jsonString, Encoding.UTF8, "application/json");

            byte[] fileByteArray = File.ReadAllBytes(@"C:/Users/hhaidary/Desktop/pdf/test.pdf");
            ByteArrayContent content = new ByteArrayContent(fileByteArray);

            content.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data");
            content.Headers.ContentDisposition.Name = "\"file\"";
            content.Headers.ContentDisposition.FileName = "\"test.pdf\"";
            content.Headers.ContentType = new MediaTypeHeaderValue("application/pdf");

            MultipartFormDataContent form = new MultipartFormDataContent();
            form.Add(content, "\"file\"", "\"test.pdf\"");
            form.Add(jsonContent, "\"payload\"");

            HttpClient myClient = new HttpClient();
            myClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", apiKey);
            myClient.DefaultRequestHeaders.Add("Accept", "application/json");

            var response = myClient.PostAsync(new Uri(url) + "/packages/", form).Result;
            Debug.WriteLine(response.Content.ReadAsStringAsync().Result);
        }
    }
Also, here is my json payload for readability:
{
  "roles": [
    {
      "id": "Dealer",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "John",
          "lastName": "Smith",
          "email": "john.smith@example.com"
        }
      ],
      "name": ""
    },
    {
      "id": "Signer0",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "SIGNER_FIRST_NAME",
          "lastName": "SIGNER_LAST_NAME",
          "email": "signer.email@example.com"
        }
      ],
      "name": ""
    },
    {
      "id": "Signer1",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "test",
          "lastName": "test",
          "email": "test@example.com"
        }
      ],
      "name": ""
    }
  ],
  "documents": [
    {
      "name": "TEST2 32.pdf",
      "index": 0,
      "approvals": [
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Dealer Signature",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 16,
                "leftOffset": 10,
                "topOffset": -28
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Dealer"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Dealer Signature",
                "index": 1,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 16,
                "leftOffset": 10,
                "topOffset": -28
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Dealer"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signed for and on behalf of Dealer",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "BOTTOMLEFT",
                "characterIndex": 1,
                "leftOffset": -5,
                "topOffset": 3
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Dealer"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Customer Signature(s)",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 200,
                "topOffset": -10
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer0"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature of Customer(s)",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "BOTTOMLEFT",
                "characterIndex": 0,
                "leftOffset": 0,
                "topOffset": 10
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer0"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature of Indemnifier",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 110,
                "topOffset": 5
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer0"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature(s) of Customer(s)",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 50,
                "topOffset": 20
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer0"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Customer Signature(s)",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 395,
                "topOffset": -10
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer1"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature of Customer(s)",
                "index": 1,
                "width": 150,
                "height": 40,
                "anchorPoint": "BOTTOMLEFT",
                "characterIndex": 0,
                "leftOffset": 0,
                "topOffset": 10
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer1"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature of Indemnifier",
                "index": 1,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 110,
                "topOffset": 5
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer1"
        },
        {
          "fields": [
            {
              "type": "SIGNATURE",
              "width": 200,
              "height": 50,
              "extract": false,
              "extractAnchor": {
                "text": "Signature(s) of Customer(s)",
                "index": 0,
                "width": 150,
                "height": 40,
                "anchorPoint": "TOPRIGHT",
                "characterIndex": 1,
                "leftOffset": 245,
                "topOffset": 20
              },
              "left": 0,
              "subtype": "FULLNAME",
              "top": 0
            }
          ],
          "role": "Signer1"
        }
      ],
      "extract": true
    }
  ],
  "name": "Test Package REST",
  "type": "PACKAGE",
  "language": "en",
  "emailMessage": "",
  "description": "New Package",
  "autoComplete": true,
  "status": "SENT"
}
Let me know if your client runs into any issues.

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off