Adding Signatures
  • 15 Oct 2024
  • 7 Minutes to read
  • Dark
    Light
  • PDF

Adding Signatures

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDKREST APIAPEX SDK

Java SDK

To download the full code sample see our Code Share site.

Adding a Signature to a Document

To add a signature to a document, you will first need to create your Signature object using the OneSpan Sign SignatureBuilder. The following code will do this:

// Fullname signature style
Signature signature1 = SignatureBuilder.signatureFor("john.smith@example.com")
    .onPage(0)
    .atPosition(215, 510)
    .withSize(200, 50)
    .withId(new SignatureId("signature1"))
    .build();

// Handwritten signature style
Signature signature2 = SignatureBuilder.captureFor("john.smith@example.com")
    .onPage(0)
    .atPosition(215, 510)
    .withSize(200, 50)
    .withId(new SignatureId("signature2"))
    .build();

// Initials signature style
Signature signature3 = SignatureBuilder.initialsFor("john.smith@example.com")
    .onPage(0)
    .atPosition(215, 510)
    .withSize(200, 50)
    .withId(new SignatureId("signature3"))
    .build();

DocumentPackage createdPackage = client.getPackageService().getPackage(packageId);

Once you have built your Signature object,  retrieve your transaction using the OneSpan Sign client. Then, using the OneSpan Sign ApprovalService,  add your signature to your document. Use the DocumentPackage, Signature objects, and documentID as parameters. The following code will do this:

client.getApprovalService().addSignature(createdPackage, documentId, signature1);

Updating a Signature On a Document

You can update a signature that has already been associated with a document. The following code will do this:

Signature updatedSignature = SignatureBuilder.captureFor("john.smith@example.com")
    .onPage(0)
    .atPosition(215, 510)
    .withSize(300, 50)
    .withId(new SignatureId("signature1"))
    .build();

List<Signature> signatures = new ArrayList<>();
signatures.add(updatedSignature);

DocumentPackage updatedPackage = client.getPackageService().getPackage(packageId);
client.getApprovalService().updateSignatures(updatedPackage, documentId, signatures);

When updating a signature, your new Signature object must have the same id as the signature you want to update.

Deleting a Signature From a Document

Deleting a signature from a document is  done using the OneSpan Sign ApprovalService. Use the PackageID, SignatureID, and documentID as parameters. The following code will do this:

client.getApprovalService().deleteSignature(packageId, documentId, new SignatureId("signature1"));

Results

Once you have run your code, your signatures will appear in your transaction's documents.

.NET SDK

To download the full code sample see our Code Share site.

Adding a Signature to a Document

To add a signature to a document, you will first need to create your Signature object using the OneSpan Sign SignatureBuilder. The following code will do this:

// Fullname signature style
Signature signature1 = SignatureBuilder.SignatureFor("john.smith@example.com")
    .OnPage(0)
    .AtPosition(215, 510)
    .WithSize(200, 50)
    .WithId(new SignatureId("signature1"))
    .Build();

// Handwritten signature style
Signature signature2 = SignatureBuilder.CaptureFor("john.smith@example.com")
    .OnPage(0)
    .AtPosition(215, 510)
    .WithSize(200, 50)
    .WithId(new SignatureId("signature2"))
    .Build();

// Initials signature style
Signature signature3 = SignatureBuilder.InitialsFor("john.smith@example.com")
    .OnPage(0)
    .AtPosition(215, 510)
    .WithSize(200, 50)
    .WithId(new SignatureId("signature3"))
    .Build();

DocumentPackage createdPackage = client.GetPackage(packageId);

Once you have built your Signature object,  retrieve your transaction using the OneSpan Sign client. Then, using the OneSpan Sign ApprovalService,  add your signature to your document. Use the DocumentPackage, Signature objects, and documentID as parameters. The following code will do this:

client.ApprovalService.AddApproval(createdPackage, documentId, signature1);

Updating a Signature On a Document

You can update a signature that has already been associated with a document. The following code will do this:

Signature updatedSignature = SignatureBuilder
    .CaptureFor("john.smith@example.com")
    .OnPage(0)
    .AtPosition(215, 510)
    .WithSize(300, 50)
    .WithId(new SignatureId("signature1"))
    .Build();

IList<Signature> signatures = new List<Signature>();
signatures.Add(updatedSignature);

DocumentPackage updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);

When updating a signature, your new Signature object must have the same id as the signature you want to update.

Deleting a Signature From a Document

Deleting a signature from a document is  done using the OneSpan Sign ApprovalService. Use the PackageID, SignatureID, and documentID as parameters. The following code will do this:

Signature updatedSignature = SignatureBuilder
    .CaptureFor("john.smith@example.com")
    .OnPage(0)
    .AtPosition(215, 510)
    .WithSize(300, 50)
    .WithId(new SignatureId("signature1"))
    .Build();

IList<Signature> signatures = new List<Signature>();
signatures.Add(updatedSignature);

DocumentPackage updatedPackage = client.GetPackage(packageId);
client.ApprovalService.UpdateApprovals(updatedPackage, documentId, signatures);

// Deleting the approval
client.ApprovalService.DeleteApproval(packageId, documentId, "signature1");

Results

Once you have run your code, your signatures will appear in your transaction's documents.

REST API

To download the full code sample see our Code Share site.

Adding a Signature to a Document

To add a signature to a document, you will first need to edit the fields object. The following code will do this:

HTTP Request

POST /api/packages/{packageId}/documents/{documentId}/approvals

HTTP Headers

Accept: application/json   
Content-Type: application/json   
Authorization: Basic api_key 

Request Payload

{
    "role": "Signer1",
    "id": "signature1",
    "fields": [
        {
            "top": 510,
            "left": 215,
            "width": 200,
            "height": 50,
            "page": 0,
            "type": "SIGNATURE",
            "subtype": "FULLNAME"
        }
    ]
}
{
    "role": "Signer1",
    "id": "signature1",
    "fields": [
        {
            "top": 510,
            "left": 215,
            "width": 200,
            "height": 50,
            "page": 0,
            "type": "SIGNATURE",
            "subtype": "CAPTURE"
        }
    ]
}
{
    "role": "Signer1",
    "id": "signature1",
    "fields": [
        {
            "top": 510,
            "left": 215,
            "width": 200,
            "height": 50,
            "page": 0,
            "type": "SIGNATURE",
            "subtype": "INITIALS"
        }
    ]
}

For a complete description of each field, see the Request Payload table below.

Response Payload

{
    "signed": null,
    "role": "Signer1",
    "accepted": null,
    "id": "signature1",
    "data": null,
    "fields": [
        {
            "top": 50,
            "left": 300,
            "height": 50,
            "page": 0,
            "type": "SIGNATURE",
            "validation": null,
            "binding": null,
            "width": 200,
            "subtype": "FULLNAME",
            "extract": false,
            "extractAnchor": null,
            "id": "tx1qz7485780",
            "data": null,
            "value": "",
            "name": ""
        }
    ],
    "name": ""
}

Updating a Signature On a Document

You can update a signature that has already been associated with a document. To update a signature, you will need to make a PUT request to:

 https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}/approvals/{signatureId}/ 

With the updated signature parameters:

{
    "role": "Signer1",
    "fields": [
        {
            "top": 510,
            "left": 215,
            "width": 300,
            "height": 50,
            "id": "signature1",
            "page": 0,
            "type": "SIGNATURE",
            "subtype": "CAPTURE"
        }
    ]
}

When updating a signature, your new Signature object must have the same id as the signature you want to update.

Deleting a Signature From a Document

Finally, deleting a signature is done by making a DELETE request to:

 https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}/approvals/{signatureId}/ 

Results

Once you have run your code, your signatures will appear in your transaction's documents.

Request Payload Table

Property

Type

Editable

Required

Default

Sample Values

role

string

Yes

No

n/a

Signer1

id

string

Yes

No

n/a

signature1

fields

top

integer

Yes

No

0

510

left

integer

Yes

No

0

215

width

integer

Yes

No

200

200

height

integer

Yes

No

50

50

page

integer

Yes

No

0

0

type

string

Yes

No

n/a

SIGNATURE / INPUT

subtype

string

Yes

No

n/a

FULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST

APEX SDK

To download the full code sample see our Code Share site.

Adding a Signature to a Document

To add a signature to a document, you will first need to create your Approvalobject. The following code will do this:

// #1. Add signature

// Fullname signature style
ESignLiveAPIObjects.Field field_fullname = new ESignLiveAPIObjects.Field();
field_fullname.id = 'field_fullname';
field_fullname.type = 'SIGNATURE';
field_fullname.subtype = 'FULLNAME';
field_fullname.page = 0;
field_fullname.top = 100.0;
field_fullname.left = 50.0;
field_fullname.width = 150.0;
field_fullname.height = 50.0;

ESignLiveAPIObjects.Approval approval_fullname = new ESignLiveAPIObjects.Approval();
approval_fullname.fields = new List<ESignLiveAPIObjects.Field>{field_fullname};
approval_fullname.id = 'approval_fullname';
approval_fullname.role = roleId;

// Capture signature style
ESignLiveAPIObjects.Field field_capture = new ESignLiveAPIObjects.Field();
field_capture.id = 'field_capture';
field_capture.type = 'SIGNATURE';
field_capture.subtype = 'CAPTURE';
field_capture.page = 0;
field_capture.top = 200.0;
field_capture.left = 50.0;
field_capture.width = 150.0;
field_capture.height = 50.0;

ESignLiveAPIObjects.Approval approval_capture = new ESignLiveAPIObjects.Approval();
approval_capture.fields = new List<ESignLiveAPIObjects.Field>{field_capture};
approval_capture.id = 'approval_capture';
approval_capture.role = roleId;

// Initials signature style
ESignLiveAPIObjects.Field field_initials = new ESignLiveAPIObjects.Field();
field_initials.id = 'field_initials';
field_initials.type = 'SIGNATURE';
field_initials.subtype = 'INITIALS';
field_initials.page = 0;
field_initials.top = 300.0;
field_initials.left = 50.0;
field_initials.width = 150.0;
field_initials.height = 50.0;

ESignLiveAPIObjects.Approval approval_initials = new ESignLiveAPIObjects.Approval();
approval_initials.fields = new List<ESignLiveAPIObjects.Field>{field_initials};
approval_initials.id = 'approval_initials';
approval_initials.role = roleId;

Once you have built your Signature object, use the OneSpan Sign SDK client to add your signature to your document.  Use the PackageID, Signature object, and documentID as parameters. The following code will do this:

  ESignLiveSDK sdk = new ESignLiveSDK();   //String packageId, String documentId,ESignLiveAPIObjects.Approval approval   sdk.addSignature(packageId, documentId, approval_fullname);   sdk.addSignature(packageId, documentId, approval_capture);   sdk.addSignature(packageId, documentId, approval_initials); 

Updating a Signature On a Document

You can update a signature that has already been associated with a document. The following code will do this:

ESignLiveSDK sdk = new ESignLiveSDK();

// String packageId, String documentId, ESignLiveAPIObjects.Approval approval
sdk.addSignature(packageId, documentId, approval_fullname);
sdk.addSignature(packageId, documentId, approval_capture);
sdk.addSignature(packageId, documentId, approval_initials);

When updating a signature, your new Signature object must have the same id as the signature you want to update.

Deleting a Signature From a Document

Deleting a signature from a document is  done using the OneSpan Sign SDK Client. Use the PackageID, ApprovalID, and documentID as parameters. The following code will do this:

// #4. Delete signature
sdk.deleteApproval(packageId, documentId, 'approval_fullname');

Results

Once you have run your code, your signatures will appear in your transaction's documents.


Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.
ESC

Ozzy, our interactive help assistant