Document Extraction looks for appropriately named signatures and fields in an uploaded PDF document, and for each one, it creates a OneSpan Sign signature or field. The positions and sizes of the signatures and fields from the PDF are automatically retained in OneSpan Sign.

Document Extraction is available only in the API call that uploads the document. It is not available in subsequent calls.

The information needed to create each OneSpan Sign signature or field is taken from the name of the PDF signature or field.

Naming Conventions

To create a OneSpan Sign signature field, the PDF field must have a name of the form [Signer.SigStyle#], where:

  • Signer is the custom ID of the signer.
  • SigStyle# is a signature style (Capture, Initials, or Fullname) combined with an integer for uniqueness. For example: Capture1 or Fullname09.

If you want the signature field to be optional, simply use the following format: [Signer.SigStyle#.Optional].

To create an unbound OneSpan Sign field, the PDF field must have a name of the form [Signer.SigStyle#.FieldStyle#], where:

  • Signer.SigStyle# identifies the signature associated with this field.
  • FieldStyle# is a field style (Textfield or Checkbox) combined with an integer for uniqueness. For example: Textfield2 or Checkbox6.

To create a bound OneSpan Sign field, the PDF field must have a name of the form [Signer.SigStyle#.label#.Binding], where:

  • Signer.SigStyle# identifies the signature associated with this field.
  • label# is an identifier of the field, consisting of the word label combined with an integer for uniqueness.
  • Binding is a field style. The possible values are Date or {approval.signed}, Name or {signer.name}, Title or {signer.title}, and Company or {signer.company}. Both members of each pair signify the same field style.

All parts of a PDF field name are matched using case-insensitive matches. For example, a field named [Agent1.Fullname1.label1.Date] is treated the same as a field named [AGENT1.FULLNAME1.LABEL1.DATE]. Field names are alphanumeric. They cannot contain special characters other than the underscore (_).

Example

Here is an example. Suppose a package has two signers whose custom IDs are Agent1 and Client1. Further suppose that extraction is enabled, and that a PDF is uploaded which has fields with the following names:

[Agent1.Fullname1]
[Agent1.Fullname1.label1.Date]
[Agent1.Fullname1.Textfield1]
[Agent1.Fullname1.Checkbox1]
[Agent1.Fullname2.Optional]
				
[Client1.Capture1]
[Client1.Capture1.label1.Name]
[Client1.Capture1.label2.Date]
[Client1.Capture1.label3.Title]
[Client1.Initials1]
[Client1.Initials2]

Before signing, Agent1 must complete two fields:

[Agent1.Fullname1.Textfield1]
[Agent1.Fullname1.Checkbox1]

Once those fields are complete, Agent1 can sign [Agent1.Fullname1], and [Agent1.Fullname1.label1.Date] will automatically be filled with the date of signing.

Client1 needs to sign in three places:

[Client1.Initials1]
[Client1.Initials2]
[Client1.Capture1]

Once these are all signed, the remaining fields will be filled:

[Client1.Capture1.label1.Name]
[Client1.Capture1.label2.Date]
[Client1.Capture1.label3.Title]
			

Other Extraction Methods

You may also be interested in our other extraction types:

The document extraction feature automatically creates all signatures and fields that exist in an uploaded PDF file. The positions and sizes of the signatures and fields in the PDF file are automatically retained in OneSpan Sign.

Configuring the PDF Form Fields

First, you will need a PDF with form fields, named how OneSpan Sign can recognize them. You can see more about the proper format of the form field names from the feature overview. Below is the PDF document that is used in this guide. The form field names on the fields are shown in the image below.

formFieldPDF

As you can see, the two signers on the document will be Signer1 and Preparer1. These will be the custom IDs used in the code section below to let OneSpan Sign know what fields to associate with each signer.

PDF used in this guide can be found here.

The Code

The sample code below shows you how to setup your document package (transaction in the new UI) for document extraction. In each withSigner call, you will see that the custom IDs coincide with the ones in the image of the PDF form shown earlier in the guide. The .withDocument also has a call to enableExtraction.

Because this is done, you might notice that you do not have to define the signature locations and who needs to sign the document. This is already taken care of with the IDs and the associated form field names from the PDF.

DocumentPackage superDuperPackage = newPackageNamed("Test Document Extraction")
            	.withSettings(newDocumentPackageSettings())
            	.withSigner(newSignerWithEmail("[email protected]" )
                    	.withCustomId("Signer1")
                    	.withFirstName("John")
                    	.withLastName("Smith"))
            	.withSigner(newSignerWithEmail("[email protected]")
                    	.withFirstName("Michael")
                    	.withLastName("Williams")
                    	.withCustomId("Preparer1"))
            	.withDocument(newDocumentWithName("testDocumentExtraction")
                    	.fromStream(documentStream, DocumentType.PDF)
                    	.enableExtraction())
            	.build();

What it looks like

After running your code, the package is created with the appropriate fields for each signer. This is what Signer1 will see:

formFieldPDFPackageSignerView

As you see, the required fields are highlighted for the user to fill out. The Name field will be filled in automatically by OneSpan Sign when the signing is complete. Likewise, the preparer sees this:

formFieldPDFPackagePreparerView

Get the Code

The document extraction feature automatically creates all signatures and fields that exist in an uploaded PDF file. The positions and sizes of the signatures and fields in the PDF file are automatically retained in OneSpan Sign.

Configuring the PDF Form Fields

First, you will need a PDF with form fields, named how OneSpan Sign can recognize them. You can see more about the proper format of the form field names from the feature overview. Below is the PDF document that is used in this guide. The form field names on the fields are shown in the image below.

formFieldPDF

As you can see, the two signers on the document will be Signer1 and Preparer1. These will be the custom IDs used in the code section below to let OneSpan Sign know what fields to associate with each signer.

PDF used in this guide can be found here.

The Code

The sample code below shows you how to setup your document package (transaction in the new UI) for document extraction. In each withSigner call, you will see that the custom IDs coincide with the ones in the image of the PDF form shown earlier in the guide. The .withDocument also has a call to enableExtraction.

Because this is done, you might notice that you do not have to define the signature locations and who needs to sign the document. This is already taken care of with the IDs and the associated form field names from the PDF.

DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Test Document Extraction")
                .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings())
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("John")
                                .WithLastName("Smith")
                                .WithCustomId("Signer1")
                    )
                    .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]")
                                .WithFirstName("Michael")
                                .WithLastName("Williams")
                                .WithCustomId("Preparer1")
                    )
                    .WithDocument(DocumentBuilder.NewDocumentNamed("testDocumentExtraction")
                                  .FromStream(fileStream1, DocumentType.PDF)
                                  .EnableExtraction()
                                 )
                    .Build();

What it looks like

After running your code, the package is created with the appropriate fields for each signer. This is what Signer1 will see:

formFieldPDFPackageSignerView

As you see, the required fields are highlighted for the user to fill out. The Name field will be filled in automatically by OneSpan Sign when the signing is complete. Likewise, the preparer sees this:

formFieldPDFPackagePreparerView

Get the Code

The document extraction feature automatically creates all signatures and fields that exist in an uploaded PDF file. The positions and sizes of the signatures and fields in the PDF file are automatically retained in OneSpan Sign.

Configuring the PDF Form Fields

First, you will need a PDF with form fields, named how OneSpan Sign can recognize them. You can see more about the proper format of the form field names from the feature overview. Below is the PDF document that is used in this guide. The form field names on the fields are shown in the image below.

formFieldPDF

As you can see, the two signers on the document will be Signer1 and Preparer1. These will be the custom IDs used in the code section below to let OneSpan Sign know what fields to associate with each signer.

PDF used in this guide can be found here.

The Code

Typically, you will probably build your JSON string dynamically versus having a giant static string, like this. This is to give a good representation of the structure of the JSON you will need to create your package (transaction in the new UI) properly.

The JSON below is formatted for readability. In each roles object, you will see that the custom IDs coincide with the ones in the image of the PDF form shown earlier in the guide. The documents object also has extract to true.

Because this is done, you might notice that you do not have to define the signature locations and who needs to sign the document. This is already taken care of with the IDs and the associated form field names from the PDF.

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":"Preparer1",
            	"type":"SIGNER",
            	"signers":[
            	{
                    	"firstName":"Michael",
                    	"lastName":"Williams",
                    	"phone":"",
                    	"email":"[email protected]",
                    	"delivery":
                    	{
                            	"email":true,
                            	"provider":false,
                            	"download":true
                    	},
                    	"id":"Preparer1"
            	}],
            	"name":"Sender"
    	},
    	{
            	"id":"Signer1",
            	"type":"SIGNER",
            	"signers":[
            	{
                    	"firstName":"John",
                    	"lastName":"Smith",
                    	"email":"[email protected]",
                    	"delivery":
                    	{
                            	"email":false,
                            	"provider":false,
                            	"download":false
                    	},
                    	"id":"Signer1"
            	}],
            	"name":"Signer"
    	}],
    	"documents":[
    	{
            	"name": "testDocumentExtraction",
             	"extract": true
    	}],
    	"name": "Test Document Extraction",
    	"type":"PACKAGE",
    	"autoComplete":true,
    	"status":"SENT"
}
------WebKitFormBoundary1bNO60n7FqP5WO4t--

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

Response Payload

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

What it looks like

After running your code, the package is created with the appropriate fields for each signer. This is what Signer1 will see:

formFieldPDFPackageSignerView

As you see, the required fields are highlighted for the user to fill out. The Name field will be filled in automatically by OneSpan Sign when the signing is complete. Likewise, the preparer sees this:

formFieldPDFPackagePreparerView

Get the Code

Request Payload

PropertyTypeEditableRequiredDefaultSample Value(s)
statusstringYesNoDRAFTDRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
autoCompletebooleanYesNotruetrue / false
typestringYesNoPACKAGEPACKAGE / TEMPLATE / LAYOUT
namestringYesYesn/aTest Document Extraction
documents
namestringYesNon/atestDocumentExtraction
extractbooleanYesNofalsetrue / false
roles
idstringYesNon/aPreparer1
namestringYesNon/aSender
typestringYesNoSIGNERSIGNER / SENDER
signers
emailstringYesYesn/a[email protected]
firstNamestringYesYesn/aMichael
lastNamestringYesYesn/aWilliams
phonestringYesNon/a514-555-8888
idstringYesNon/aPreparer1
delivery
emailbooleanYesNofalsetrue / false
providerbooleanYesNofalsetrue / false
downloadbooleanYesNofalsetrue / false
The document extraction feature automatically creates all signatures and fields that exist in an uploaded PDF file. The positions and sizes of the signatures and fields in the PDF file are automatically retained in OneSpan Sign.

Configuring the PDF Form Fields

First, you will need a PDF with form fields, named how OneSpan Sign can recognize them. You can see more about the proper format of the form field names from the feature overview. Below is the PDF document that is used in this guide. The form field names on the fields are shown in the image below.

formFieldPDF

As you can see, the two signers on the document will be Signer1 and Preparer1. These will be the Role Name used in the code section below to let OneSpan Sign know what fields to associate with each signer.

PDF used in this guide can be found here.

The Code

The sample code below shows you how to setup your document package (transaction in the new UI) for document extraction. In each Role object, you will see that the name attributes coincide with the ones in the image of the PDF form shown earlier in the guide. In the Document object, extract attribute is also set to true.

Because this is done, you might notice that you do not have to define the signature locations and who needs to sign the document. This is already taken care of with the Role Names and the associated form field names from the PDF.

    	ESignLiveSDK sdk = new ESignLiveSDK();
         
        //Create package
        ESignLiveAPIObjects.Package_x pkg = new ESignLiveAPIObjects.Package_x();
        pkg.name = 'Test Document Extraction - ' + Datetime.now().format();
        pkg.status = ESignLiveAPIObjects.PackageStatus.DRAFT;
        
        //Create Roles
        String roleId1 = 'Signer1';
        ESignLiveAPIObjects.Role role1 = new ESignLiveAPIObjects.Role();
        role1.signers = sdk.createRolesSigner('sigenr1_firstname', 'signer1_lastname', '[email protected]', 'CEO', 'ABC Bank');
        role1.id = roleId1;
        role1.name = roleId1;
        
        String roleId2 = 'Preparer1';
        ESignLiveAPIObjects.Role role2 = new ESignLiveAPIObjects.Role();
        role2.signers = sdk.createRolesSigner('sigenr2_firstname', 'signer2_lastname', '[email protected]', 'Applicant', 'ABC Company');
        role2.id = roleId2;
        role2.name = roleId2;
        
        pkg.roles = new List<ESignLiveAPIObjects.Role>{role1,role2};    //add role
        
        //Prepare Documents Blob
        String document1Name = 'Sample_Document_Extraction';
        StaticResource sr = [SELECT Id, Body FROM StaticResource WHERE Name = 'test_document_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;
        
        pkg.documents = new List<ESignLiveAPIObjects.Document>{document1};    //add document
        
    	//Send package One Step
        String packageId = sdk.createPackage(pkg,documentBlobMap);
        System.debug('PackageId: ' + packageId);

What it looks like

After running your code, the package is created with the appropriate fields for each signer. This is what Signer1 will see:

formFieldPDFPackageSignerView

As you see, the required fields are highlighted for the user to fill out. The Name field will be filled in automatically by OneSpan Sign when the signing is complete. Likewise, the Preparer sees this:

formFieldPDFPackagePreparerView

Get the Code