To download the full code sample see our Code Share site. For information on using Position Extraction with Conditional Fields, see Position Extraction + Conditional Fields.

The Position Extraction feature ensures that the exact position and size of a field or signature in an uploaded PDF file are automatically retained in OneSpan Sign.

The following sample code shows you how to edit the document block object with position extraction.

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.

 .withDocument(newDocumentWithName("First Document")   .fromFile("DOC_FILE_PATH")   .enableExtraction()   .withSignature(signatureFor("[email protected]")   .withName("sig1")   .withPositionExtracted())   ) 

Ensure that you have the enableExtraction() call set at the document level and that your PDF document contains a field named sig1. Otherwise, an error will be thrown.

Results

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

Capture

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

The Position Extraction feature ensures that the exact position and size of a field or signature in an uploaded PDF file are automatically retained in OneSpan Sign.

The following sample code shows you how to edit the document block object with position extraction.

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.

 .WithDocument(DocumentBuilder.NewDocumentNamed("First Document")   .FromFile("C:/Users/hhaidary/Desktop/pdf/working.pdf")   .EnableExtraction()   .WithSignature(SignatureBuilder.SignatureFor("[email protected]")   .WithName("sig1")   .WithPositionExtracted())   ) 

Ensure that you have the enableExtraction() call set at the document level and that your PDF document contains a field named sig1. Otherwise, an error will be thrown.

Results

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

Capture

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

The Position Extraction feature ensures that the exact position and size of a field or signature in an uploaded PDF file are automatically retained in OneSpan Sign.

The following sample code shows you how to edit the document block object with position extraction.

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.

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"   
{
  "roles": [
    {
      "id": "Signer1",
      "type": "SIGNER",
      "signers": [
        {
          "firstName": "John",
          "lastName": "Smith",
          "email": "[email protected]"
        }
      ],
      "name": "Signer1"
    }
  ],
  "documents": [
    {
      "approvals": [
        {
          "fields": [
            {
              "type": "INPUT",
              "extract": true,
              "subtype": "LABEL",
              "name": "name1",
              "binding": "{signer.name}"
            },
            {
              "type": "INPUT",
              "extract": true,
              "subtype": "TEXTFIELD",
              "name": "age1"
            },
            {
              "type": "INPUT",
              "extract": true,
              "subtype": "TEXTFIELD",
              "name": "address1"
            },
            {
              "type": "INPUT",
              "extract": true,
              "subtype": "TEXTFIELD",
              "name": "zip1"
            },
            {
              "type": "INPUT",
              "extract": true,
              "subtype": "TEXTFIELD",
              "name": "city1"
            },
            {
              "type": "SIGNATURE",
              "extract": true,
              "subtype": "FULLNAME",
              "name": "sig1"
            }
          ],
          "role": "Signer1"
        }
      ],
      "extract": true,
      "name": "Sample Contract"
    }
  ],
  "name": "Field Position Extraction Example",
  "type": "PACKAGE",
  "language": "en",
  "autoComplete": true,
  "status": "DRAFT"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t-- 

Ensure that you have “extract” : true set at the document level and that your PDF document contains fields named name1, age1, address1, zip1, city1 and sig1. If you do not, an error will be thrown.

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

Response Payload

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

Results

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

Capture

Request Payload Table

Property  TypeEditableRequiredDefaultSample Values
status  stringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
autoComplete  booleanYesNotruetrue / false
type  stringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
name  stringYesYesn/aField Position Extraction Example
documents       
name  stringYesNon/aSample Contract
extract  booleanYesNofalsetrue / false
approvals       
 role stringYesNon/aSigner1
 fields      
  typestringYesYesn/aSIGNATURE / INPUT
  extractbooleanYesNofalsetrue / false
  subtypestringYesYesn/aFULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
  namestringYesNon/asig1
  valuestringYesNon/aFULLNAME / INITIALS / CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / RADIO / LIST
  bindingstringYesNonull{approval.signed} / {signer.title} / {signer.name} / {signer.company}
roles       
id  stringYesNon/aSigner1
name  stringYesNon/aSender
type  stringYesNoSIGNERSIGNER / SENDER
signers       
 email stringYesYesn/a[email protected]
 firstName stringYesYesn/aJohn
 lastName stringYesYesn/aSmith

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

The Position Extraction feature ensures that the exact position and size of a field or signature in an uploaded PDF file are automatically retained in OneSpan Sign.

The following sample code shows you how to edit the document block object with position extraction.

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.

  //Prepare Documents Blob   String document1Name = 'Sample_Position_Extraction';   StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'test_position_extraction' LIMIT 1];   Map<String,Blob> documentBlobMap = new Map<String,Blob>();   documentBlobMap.put(document1Name, sr.Body);   //Create Document Metadata   ESignLiveAPIObjects.Document document1 = new ESignLiveAPIObjects.Document();   document1.name = document1Name;   document1.id = document1Name;   document1.extract = true;   //document level extraction:true   ESignLiveAPIObjects.Approval approval1 = new ESignLiveAPIObjects.Approval();   approval1.role = roleId1;   approval1.id = 'approval1';   ESignLiveAPIObjects.Field field1 = new ESignLiveAPIObjects.Field();   field1.id = 'signature1';   field1.extract = true;   field1.name = 'sig1';   //match pdf field property name   field1.type = 'SIGNATURE';   field1.subtype = 'FULLNAME';   approval1.fields = new List<ESignLiveAPIObjects.Field>{field1};   document1.approvals = new List<ESignLiveAPIObjects.Approval>{approval1};   pkg.documents = new List<ESignLiveAPIObjects.Document>{document1}; //add document 

Ensure that you have the enableExtraction() call set at the document level and that your PDF document contains a field named sig1. Otherwise, an error will be thrown.

Results

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

Capture