- 15 Oct 2024
- 6 Minutes to read
- DarkLight
- PDF
Injecting Field Values
- Updated on 15 Oct 2024
- 6 Minutes to read
- DarkLight
- PDF
Java SDK.NET SDKREST APIAPEX SDK
Java SDK
To download the full code sample see our Code Share site. The PDF used in this topic can be found here. You can also see this feature in our Interactive Demo.
While this topic describes how to inject text fields into a document, the same procedure can be used to inject any type of unbound field. For more information on the types of unbound fields that are available, see Form Building Fields.
If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see Creating and Sending a Transaction.
The sample code below shows you how to edit the document block for injecting text fields. The withName() method is used to input the name of the PDF form field you want to inject text into, as it is named in your PDF form. The withValue() method is used as the text you want to stamp on your document.
.withDocument(DocumentBuilder.newDocumentWithName("Sample Contract")
.enableExtraction()
.fromStream(fs, DocumentType.PDF)
.withInjectedField(FieldBuilder.textField()
.withName("Text1")
.withValue("200 E MAIN ST, PHOENIX AZ, 85123 USA"))
.withInjectedField(FieldBuilder.textField()
.withName("Text2")
.withValue("Lawn mower"))
.withInjectedField(FieldBuilder.textField()
.withName("Text3")
.withValue("Fertilizer"))
.withInjectedField(FieldBuilder.textField()
.withName("Text4")
.withValue("100"))
.withInjectedField(FieldBuilder.textField()
.withName("Text5")
.withValue("12 12 12"))
)
Results
Once you have run your code, your text fields will appear in your transaction's documents.
.NET SDK
To download the full code sample see our Code Share site. The PDF used in this topic can be found here. You can also see this feature in our Interactive Demo.
While this topic describes how to inject text fields into a document, the same procedure can be used to inject any type of unbound field. For more information on the types of unbound fields that are available, see Form Building Fields.
If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see Creating and Sending a Transaction.
The sample code below shows you how to edit the document block for injecting text fields. The withName() method is used to input the name of the PDF form field you want to inject text into, as it is named in your PDF form. The withValue() method is used as the text you want to stamp on your document.
.WithDocument(DocumentBuilder.NewDocumentNamed("sample contract")
.EnableExtraction()
.FromStream(fs, DocumentType.PDF)
.WithInjectedField(FieldBuilder.TextField()
.WithId("Text1")
.WithName("Text1")
.WithValue("200 E MAIN ST, PHOENIX AZ, 85123 USA"))
.WithInjectedField(FieldBuilder.TextField()
.WithId("Text2")
.WithName("Text2")
.WithValue("Lawn mower"))
.WithInjectedField(FieldBuilder.TextField()
.WithId("Text3")
.WithName("Text3")
.WithValue("Fertilizer"))
.WithInjectedField(FieldBuilder.TextField()
.WithId("Text4")
.WithName("Text4")
.WithValue("100"))
.WithInjectedField(FieldBuilder.TextField()
.WithId("Text5")
.WithName("Text5")
.WithValue("12 12 12"))
)
Results
Once you have run your code, your text fields will appear in your transaction's documents.
REST API
To download the full code sample see our Code Share site. The PDF used in this topic can be found here. You can also see this feature in our Interactive Demo.
While this topic describes how to inject text fields into a document, the same procedure can be used to inject any type of unbound field. For more information on the types of unbound fields that are available, see Form Building Fields.
If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see Creating and Sending a Transaction.
The sample code below shows you how to edit the document block for injecting text fields. The withName() method is used to input the name of the PDF form field you want to inject text into, as it is named in your PDF form. The withValue() method is used as the text you want to stamp on your document.
The sample JSON below shows you how to edit the document object for injecting text fields.I n the fields object, the name attribute is the name of the PDF form field you want to inject text into. The value attribute is where you input the text you want to inject on your document. .
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" {
"documents": [{
"fields": [{
"value": "200 E MAIN ST, PHOENIX AZ, 85123 USA",
"name": "Text1"
}, {
"value": "Lawn mower",
"name": "Text2"
}, {
"value": "Fertilizer",
"name": "Text3"
}, {
"value": "100",
"name": "Text4"
}, {
"value": "12 12 12",
"name": "Text5"
}],
"extract": true,
"name": "Sample Contract"
}],
"type": "PACKAGE",
"status": "DRAFT",
"roles": [{
"id": "client",
"index": 0,
"type": "SIGNER",
"signers": [{
"email": "john.smith@example.com",
"firstName": "John",
"lastName": "Smith",
"id": "client"
}],
"name": "client"
}, {
"id": "contractor",
"index": 1,
"type": "SENDER",
"signers": [{
"email": "myemail@example.com",
"firstName": "Haris",
"lastName": "Haidary",
"id": "contractor"
}],
"name": "contractor"
}],
"name": "Field Injection Example"
}-- -- --WebKitFormBoundary1bNO60n7FqP5WO4t--
For a complete description of each field, see the Request Payload table below.
Response Payload
{
"id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="
}
Results
Once you have run your code, your text fields will appear in your transaction's documents.
Request Payload Table
Property | Type | Editable | Required | Default | Sample Values |
---|---|---|---|---|---|
status | string | Yes | No | DRAFT | DRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED |
type | string | Yes | No | PACKAGE | PACKAGE / TEMPLATE / LAYOUT |
name | string | Yes | Yes | n/a | Field Injection Example |
documents | |||||
name | string | Yes | No | n/a | Sample Contract |
extract | boolean | Yes | No | false | false / true |
fields | |||||
value | string | Yes | No | n/a | 200 E MAIN ST, PHOENIX AZ, 85123 USA |
name | string | Yes | No | n/a | Text1 |
roles | |||||
id | string | Yes | No | n/a | Client1 |
name | string | Yes | No | n/a | Client1 |
type | string | Yes | No | SIGNER | SIGNER / SENDER |
signers | |||||
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 |
APEX SDK
To download the full code sample see our Code Share site. The PDF used in this topic can be found here. You can also see this feature in our Interactive Demo.
While this topic describes how to inject text fields into a document, the same procedure can be used to inject any type of unbound field. For more information on the types of unbound fields that are available, see Form Building Fields.
If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see Creating and Sending a Transaction.
The sample code below shows you how to build the Document object for injecting text fields. The name attribute of field is where you input the name of your PDF form field you want to inject text to. The value attribute of field is the text you want to stamp on your document.
String documentId = 'document1';
StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'test_field_injection' LIMIT 1];
Map<String, Blob> doc = new Map<String, Blob>();
doc.put(documentId, sr.Body);
ESignLiveAPIObjects.Document document = new ESignLiveAPIObjects.Document();
document.name = documentId;
document.id = documentId;
document.extract = true;
// Set field injection
ESignLiveAPIObjects.Field field1 = new ESignLiveAPIObjects.Field();
field1.name = 'Text1';
field1.value = '200 E MAIN ST, PHOENIX AZ, 85123 USA';
ESignLiveAPIObjects.Field field2 = new ESignLiveAPIObjects.Field();
field2.name = 'Text2';
field2.value = 'Lawn mower';
ESignLiveAPIObjects.Field field3 = new ESignLiveAPIObjects.Field();
field3.name = 'Text3';
field3.value = 'Fertilizer';
ESignLiveAPIObjects.Field field4 = new ESignLiveAPIObjects.Field();
field4.name = 'Text4';
field4.value = '100';
ESignLiveAPIObjects.Field field5 = new ESignLiveAPIObjects.Field();
field5.name = 'Text5';
field5.value = '12 12 12';
document.fields = new List<ESignLiveAPIObjects.Field>{field1, field2, field3, field4, field5};
sdk.createDocuments(packageId, document, doc);
Results
Once you have run your code, your text fields will appear in your transaction's documents.