Position Extraction

This guide shows you how to use the position extraction feature in OneSpan Sign.

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("john.smith@email.com")
                     .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("john.smith@email.com")
                      .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": "john.smith@example.com"
        }
      ],
      "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 JSON Properties 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

JSON Properties

Property Type Editable Required Default Sample Value(s)
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 Field Position Extraction Example
documents
name string Yes No n/a Sample Contract
extract boolean Yes No false true / false
approvals
role string Yes No n/a Signer1
fields
type string Yes Yes n/a SIGNATURE / INPUT
extract boolean Yes No false true / false
subtype string Yes Yes n/a FULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
name string Yes No n/a sig1
roles
id string Yes No n/a Signer1
name string Yes No n/a Sender
type string Yes No SIGNER SIGNER / SENDER
signers
email string Yes Yes n/a john.smith@example.com
firstName string Yes Yes n/a John
lastName string Yes Yes n/a Smith