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 the OneSpan Sign system.

The Code

You can get a complete example code from the Developer Community Code Share, here. The following sample code shows you how to edit the document block object with position extraction. If you need a comparison to the basic signature object creation or if this is your first time creating a package with the Java SDK, see this guide.
.withDocument(newDocumentWithName("First Document")
         .fromFile("DOC_FILE_PATH")
         .enableExtraction()
         .withSignature(signatureFor("[email protected]")
                     .withName("sig1")
                     .withPositionExtracted())
         )
Please ensure that you have the enableExtraction() call at the document level and that your PDF document contains a field named "sig1". Otherwise, an error will be thrown.

Running Your Code

Once you've run your code, you can login into OneSpan Sign and browse to the document view of your package. Below is a screenshot of what you can expect.

Capture

Get the Code | See this feature in action in our Interactive Demo

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 the OneSpan Sign system.

The Code

You can get a complete example code from the Developer Community Code Share, here. The following sample code shows you how to edit the document block object with position extraction. If you need a comparison to the basic signature object creation or if this is your first time creating a package with the .NET SDK, see this guide.
.WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
          .FromFile("C:/Users/hhaidary/Desktop/pdf/working.pdf")
          .EnableExtraction()
          .WithSignature(SignatureBuilder.SignatureFor("[email protected]")
                      .WithName("sig1")
                      .WithPositionExtracted())
          )
Please ensure that you have the enableExtraction() call at the document level and that your PDF document contains a field named "sig1". Otherwise, an error will be thrown.

Running Your Code

Once you've run your code, you can login into OneSpan Sign and browse to the document view of your package. Below is a screenshot of what you can expect.

Capture

Get the Code | See this feature in action in our Interactive Demo

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 the OneSpan Sign system.

The Code

You can get a complete example code from the Developer Community Code Share, here. The following sample JSON shows you how to edit the document block object with position extraction. If you need a comparison to the basic signature object creation or if this is your first time creating a package with the REST API, see this guide.

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": "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--
Please ensure that you have "extract": true at the document level and that your PDF document contains a field named "sig1". Otherwise, an error will be thrown.

For a complete description of each field, take a look at the Request Payload section below.

Response Payload

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

Running Your Code

Once you've run your code, you can login into OneSpan Sign and browse to the document view of your package. Below is a screenshot of what you can expect.

Capture

Get the Code | See this feature in action in our Interactive Demo

Request Payload

PropertyTypeEditableRequiredDefaultSample Value(s)
statusstringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
autoCompletebooleanYesNotruetrue / false
typestringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
namestringYesYesn/aField Position Extraction Example
documents
namestringYesNon/aSample Contract
extractbooleanYesNofalsetrue / false
approvals
rolestringYesNon/aSigner1
fields
typestringYesYesn/aSIGNATURE / INPUT
extractbooleanYesNofalsetrue / false
subtypestringYesYesn/aFULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
namestringYesNon/asig1
roles
idstringYesNon/aSigner1
namestringYesNon/aSender
typestringYesNoSIGNERSIGNER / SENDER
signers
emailstringYesYesn/a[email protected]
firstNamestringYesYesn/aJohn
lastNamestringYesYesn/aSmith
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 the OneSpan Sign system.

The Code

You can get a complete example code from the Developer Community Code Share, here. The following sample code shows you how to build the Document object with position extraction. If you need a comparison to the basic signature object creation or if this is your first time creating a package with the Apex SDK, see this guide.
        //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
Please ensure that you enabled extract at the document level and that your PDF document contains a field named sig1.

Running Your Code

PDF used in this guide can be found here. Once you’ve run your code, you can login into OneSpan Sign and browse to the document view of your package. Below is a screenshot of what you can expect.

Capture

Get the Code | See this feature in action in our Interactive Demo