OneSpan Sign Developer: Field Font Size – Part 2

Duo Liang,

In Part 1 of this blog series, we discussed how a consistent font size benefits your document design and what options OneSpan Sign provides to specify the field font size. 

This blog will take it a step further to showcase how to use this feature as an ad-hoc user as well as an integrator. Along with the step by step guide, we will present screenshots and working code samples. Let’s get started.

Field Font Size for Ad-hoc Users

In order to specify the default font size to be used for all fields in the transaction/template, you can find the relevant setting both in transaction creation and detail pages. By expanding the “SETTINGS” section, you can find the field formatting at the bottom.7-31-1

The screenshot below shows available options for the default font size:7-31-2

During document design, all fields will then be set to this value automatically. If you want to specify a different font size for a particular field, click on the field and select “Settings” from the dropdown. 7-31-3

Then, from the popup panel, select the newly added “FIELD FORMATTING” tab where you can adjust the font size.7-31-4

For API Integrators:

In this section, we’ll dive into the JSON level and see what has been added to the schema that reflects this feature.

First for the transaction level font size setting, you can find the attribute under “settings” -- “ceremony” -- “fontSize”. The example JSON code below should give you an idea of how to specify it in a transaction metadata.

{
  "type": "PACKAGE",
  "settings": {
    "ceremony": {
      "fontSize": 14
    }
  },
  "name": "Test Transaction with Font Size Setting",
  "status": "DRAFT"
}

On top of that, if you want to configure the font size for a specific field, the attribute is accommodated under the field node with a path of “documents” -- “approvals” -- “fields” -- “fontSize”. Below is a typical JSON representing a text field with font size 14 px:

{
  "id":"text_field _1",
  "name":"text_field _1",
  "top":300,
  "left":100,
  "width":150,
  "height":50,
  "page":0,
  "type":"INPUT",
  "value":"default value",
  "binding":null,
  "subtype": "TEXTFIELD",
  "fontSize":14
}

Note: For two other types of font sizes:
1. Auto-fit can be represented by "fontSize":0
2. Inherit from parent is the default behavior, so you don’t need to explicitly set the value as "fontSize":null

For SDK Integrators:

To integrate the Field Font Size feature with either Java or .NET SDK, make sure your SDK version is later than 11.25.

Below is the equivalent code to set transaction level font size: 

Java

DocumentPackage pkg1 = PackageBuilder.newPackageNamed("Field Font Size - " + System.currentTimeMillis())
        ……
        .withSettings(DocumentPackageSettingsBuilder.newDocumentPackageSettings().withFontSize(14))	
        .build();

.NET

DocumentPackage package = PackageBuilder.NewPackageNamed("Field Font Size - " + System.currentTimeMillis())
        ……
        .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings().WithFontSize(14))
        .Build();

To specify font size per field, use below code:

Java 

.withField(FieldBuilder.textField()
	.onPage(0)
	.atPosition(100, 200)
    .withSize(150, 50)
	.withFontSize(8)			//specify font size
  //.withFontSize(0)			//auto-fit          
  //.withFontSize(null)			//inherit from parent, don’t need to explicitly set		
)			

.NET

.WithField(FieldBuilder.TextField()
                 .OnPage(0)
                 .AtPosition(100, 200)
                 .WithSize(150, 50))
                 .WithFontSize(8)           //specify font size
              //.WithFontSize(0)			//auto-fit          
              //.WithFontSize(null)			//inherit from parent, don’t need to explicitly set	
)

If you have any questions regarding this blog or anything else concerning integrating OneSpan Sign into your application, visit the Developer Community Forums. Your feedback matters to us!

OneSpan Developer Community

OneSpan Developer Community

Join the OneSpan Developer Community! Forums, blogs, documentation, SDK downloads, and more.

Join Today

Duo Liang is a Technical Evangelist and Partner Integrations Developer at OneSpan where he creates and maintains integration guides and code shares, helps customers and partners integrate OneSpan products into their applications, and builds integrations within third party platforms.