Custom Document Data
  • 10 Oct 2024
  • 4 Minutes to read
  • Dark
    Light
  • PDF

Custom Document Data

  • Dark
    Light
  • PDF

Article summary

Java SDK.NET SDKREST API

Java SDK

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

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

 DocumentPackage pkg = eslClient.getPackageService().getPackage(packageId);
Document doc = pkg.getDocument(DOCUMENT_NAME);
Map < String, Object > attributes = doc.getData();
for (Map.Entry < String, Object > entry: attributes.entrySet()) {
	System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());
} 

Retrieving your Attributes

To retrieve these attributes, use the following code:

 DocumentPackage pkg = eslClient.getPackageService().getPackage(packageId);   Document doc = pkg.getDocument(DOCUMENT_NAME);   Map<String, Object> attributes = doc.getData();   for (Map.Entry<String, Object> entry : attributes.entrySet()){   System.out.println("Key : " + entry.getKey() + " Value : " + entry.getValue());   } 

Results

Here is an example of what you can expect to see once you have run your code.

.NET SDK

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

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

 DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed(PackageName).DescribedAs("This is a package created using the OneSpan Sign SDK").WithSigner(SignerBuilder.NewSignerWithEmail(email1).WithCustomId("Client1").WithFirstName("John").WithLastName("Smith").WithTitle("Managing Director").WithCompany("Acme Inc.")).WithDocument(DocumentBuilder.NewDocumentNamed(DOCUMENT_NAME).FromStream(fileStream1, DocumentType.PDF).WithSignature(SignatureBuilder.SignatureFor(email1).OnPage(0).AtPosition(100, 100)).WithData(DocumentAttributesBuilder.NewDocumentAttributes().AddAttribute("Department", "1806").AddAttribute("Employee", "135526"))).Build();

Retrieving your Attributes

To retrieve these attributes, use the following code:

DocumentPackage pkg = eslClient.GetPackage(packageId);
Document doc = pkg.GetDocument("sample doc");
IDictionary < string, object > attributes = doc.Data;
foreach(var attribute in attributes) {
	Debug.WriteLine("Key : " + attribute.Key + " Value : " + attribute.Value);
}

Results

Here is an example of what you can expect to see once you have run your code.

REST API

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

Document attributes are customized data related to a document in a transaction, or to all data in a transaction. This data is not interpreted by OneSpan Sign. As such, the users of this data are free to store and interpret whatever data they want.

Customized data can also be applied at the transaction level. For more information, see Package Attributes.

The following code sample illustrates the simplest way to create a package with customized document attributes. This example illustrates how to create customized attributes with the keys Department, and Employee. The customized attribute data is constructed as a map.

HTTP Request

POST /api/packages

HTTP Headers

Accept: application/json   
Content-Type: multipart/form-data   
Authorization: Basic api_key 

Request Payload

 ------WebKitFormBoundary1bNO60n7FqP5WO4t   Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"   Content-Type: application/pdf   %PDF-1.5   %µµµµ   1 0 obj   <>>>   endobj....   ------WebKitFormBoundary1bNO60n7FqP5WO4t   Content-Disposition: form-data; name="payload"   {   "autocomplete": true,   "documents": [   {   "approvals": [   {   "fields": [   {   "extract": false,   "height": 50,   "left": 100,   "page": 0,   "subtype": "FULLNAME",   "top": 100,   "type": "SIGNATURE",   "width": 200   }   ],   "role": "Client1"   }   ],   "data": {   "Department": "1806",   "Employee": "135526"   },   "name": "sample doc"   }   ],   "name": "Document Attributes Example",   "roles": [   {   "id": "Client1",   "name": "Client1",   "signers": [   {   "company": "Acme Inc.",   "email": "mail32@example.com",   "firstName": "John",   "id": "Client1",   "lastName": "Smith",   "title": "Managing Director"   }   ]   }   ],   "trashed": false,   "type": "PACKAGE",   "visibility": "ACCOUNT"   }   ------WebKitFormBoundary1bNO60n7FqP5WO4t-- 

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

Response Payload

 {   "id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="   } 

If you want to retrieve your attributes at a later stage, you can do so by simply retrieving your document JSON:

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

Then, loop through the data field property.

Results

Here is an example of what you can expect to see once you have run your code.

Request Payload Table

Property

Type

Editable

Required

Default

Sample Values

status

string

Yes

No

DRAFT

DRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED

autoComplete

boolean

Yes

No

true

true / false

type

string

Yes

No

PACKAGE

PACKAGE / TEMPLATE / LAYOUT

name

string

Yes

Yes

n/a

Document Attributes Example

trashed

boolean

Yes

No

false

true / false

visibility

string

Yes

No

ACCOUNT

ACCOUNT / SENDER

documents

name

string

Yes

No

n/a

sample doc

approvals

fields

subtype

string

Yes

No

n/a

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

type

string

Yes

No

n/a

SIGNATURE / INPUT

extract

boolean

Yes

No

false

true / false

height

integer

Yes

No

50

50 / 100 / 150 ...

left

integer

Yes

No

0

50 / 100 / 150 ...

page

integer

Yes

No

0

0 / 1 / 2 ...

top

integer

Yes

No

0

50 / 100 / 150 ...

width

integer

Yes

No

200

50 / 100 / 150 ...

role

string

Yes

No

n/a

Client1

data

Department

string

Yes

No

n/a

1806

Employee

string

Yes

No

n/a

135526

roles

id

string

Yes

No

n/a

Client1

name

string

Yes

No

n/a

Client1

type

string

Yes

No

SIGNER

SIGNER / SENDER

signers

email

string

Yes

Yes

n/a

preparer.email@example.com

firstName

string

Yes

Yes

n/a

John

lastName

string

Yes

Yes

n/a

Smith

phone

string

Yes

No

n/a

514-555-8888

id

string

Yes

No

n/a

Client1

company

string

Yes

No

n/a

Acme Inc.

title

string

Yes

No

n/a

Managing Director


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

Eddy AI, facilitating knowledge discovery through conversational intelligence