---
title: "Injecting Field Values"
slug: "injecting-field-values"
updated: 2025-07-02T18:51:37Z
published: 2025-07-02T18:51:37Z
canonical: "docs.onespan.com/injecting-field-values"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://docs.onespan.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Injecting Field Values

[Java SDK](/v1/docs/injecting-field-values#java-sdk) [.NET SDK](/v1/docs/injecting-field-values#net-sdk) [REST API](/v1/docs/injecting-field-values#rest-api) [APEX SDK](/v1/docs/injecting-field-values#apex-sdk)

## Java SDK

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/injecting-fields-java-sdk/) site. The PDF used in this topic can be found [here](https://cdn.document360.io/038f59a7-abd0-4c14-9de7-3434d28b49fd/Images/Documentation/field_injection_sample.pdf). You can also see this feature in our[](https://secure.onespan.com/interactive-demo.html) [Interactive Demo.](https://secure.onespan.com/interactive-demo.html)

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.](/v1/docs/transactions-adding-fields#formbuilding-fields)

If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see [](https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-net/)[Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#net-sdk).

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.

```java
.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](https://community.onespan.com/documentation/onespan-sign/codeshare/injecting-fields-net-sdk/) site. The PDF used in this topic can be found [here](https://cdn.document360.io/038f59a7-abd0-4c14-9de7-3434d28b49fd/Images/Documentation/field_injection_sample.pdf). You can also see this feature in our[](https://secure.onespan.com/interactive-demo.html) [Interactive Demo.](https://secure.onespan.com/interactive-demo.html)

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.](/v1/docs//transactions-adding-fields#formbuilding-fields)

If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see [](https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-net/)[Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#net-sdk).

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.

```csharp
.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](https://community.onespan.com/documentation/onespan-sign/codeshare/injecting-fields-rest-api/) site. The PDF used in this topic can be found [here](https://cdn.document360.io/038f59a7-abd0-4c14-9de7-3434d28b49fd/Images/Documentation/field_injection_sample.pdf). You can also see this feature in our[](https://secure.onespan.com/interactive-demo.html) [Interactive Demo.](https://secure.onespan.com/interactive-demo.html)

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.](/v1/docs/transactions-adding-fields#formbuilding-fields)

<editor360-custom-block data-preprocessing="true" data-sanitizationtags="a"><p data-block-id="76e6c00a-5ef2-4093-8483-b7f4ba0e2b31">If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see <a href="https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-net/" target="_blank" display="false" rel="noopener"></a><a href="/v1/docs/creating-and-sending-a-transaction#net-sdk" target="_self" translate="no" rel="noopener">Creating and Sending a Transaction</a>.</p></editor360-custom-block>

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

```http
POST /api/packages
```

#### HTTP Headers

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

<editor360-custom-block data-preprocessing="true" data-sanitizationtags="a"><h4 data-block-id="cf7783f0-a61e-40ea-87da-22e22c51e683"><a name="Request" display="false"></a>Request Payload</h4></editor360-custom-block>

```json
 -- -- --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

```json
{
    "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 |  |  |  |  |  |
| 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 |

## APEX SDK

To download the full code sample see our [Code Share](https://community.onespan.com/documentation/onespan-sign/codeshare/injecting-fields-apex-sdk/) site. The PDF used in this topic can be found [here](https://cdn.document360.io/038f59a7-abd0-4c14-9de7-3434d28b49fd/Images/Documentation/field_injection_sample.pdf). You can also see this feature in our[](https://secure.onespan.com/interactive-demo.html) [Interactive Demo.](https://secure.onespan.com/interactive-demo.html)

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](/v1/docs/transactions-adding-fields#formbuilding-fields).

If you need a comparison to the basic object creation procedure, or if this is the first time creating a transaction, see [](https://developer.esignlive.com/guides/quick-start/creating-and-sending-a-package-net/)[Creating and Sending a Transaction](/v1/docs/creating-and-sending-a-transaction#apex-sdk).

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.

```plaintext
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.
