Customizing the Electronic Signature UI on Android

The Electronic Signatures UI can be customized to fit your needs.

You can customize aspects such as which signature creation modes are available and in which order, and what signing fonts to offer when creating signatures by typing.

These options are set via the ElectronicSignatureOptions class, which can be built using its Builder. You can change the available mode via signatureCreationModes, the fonts via setAvailableFonts, and the colors with signatureColorOptions.

Both signatureCreationModes and signatureColorOptions can also be configured on initialization using PdfConfiguration and PdfActivityConfiguration. setAvailableFonts is static, so it can be called at any point.

Setting Available Signature Creation Modes

signatureCreationModes accepts an array of List<SignatureCreationMode> members. Based on these entries, the UI will display the tabs specified in the array, respecting the order in which they were added. It defaults to [SignatureCreationMode.DRAW, SignatureCreationMode.IMAGE, SignatureCreationMode.TYPE].

Here’s an example offering Type, followed by Image, as signature creation modes:

// Using `PdfConfiguration`:
val configuration =
        PdfConfiguration.Builder()
            .signatureCreationModes(listOf(SignatureCreationMode.DRAW, SignatureCreationMode.TYPE))
            .build()

// Using `ElectronicSignatureOptions`:
val signatureOptions =
        ElectronicSignatureOptions.Builder()
            .signatureCreationModes(listOf(SignatureCreationMode.DRAW, SignatureCreationMode.TYPE))
            .build()
// Using `PdfConfiguration`:
final PdfConfiguration configuration =
        new PdfConfiguration.Builder()
            .signatureCreationModes(Arrays.asList(SignatureCreationMode.DRAW, SignatureCreationMode.TYPE))
            .build();

// Using `ElectronicSignatureOptions`:
final ElectronicSignatureOptions signatureOptions =
        new ElectronicSignatureOptions.Builder()
            .signatureCreationModes(Arrays.asList(SignatureCreationMode.DRAW, SignatureCreationMode.TYPE))
            .build();

You can also set the available signature colors with signatureColorOptions:

...
    .signatureColorOptions(SignatureColorOptions.fromColorInt(Color.RED, Color.GREEN, Color.BLUE))
    .build()
...
    .signatureColorOptions(SignatureColorOptions.fromColorInt(Color.RED, Color.GREEN, Color.BLUE))
    .build();

Setting Available Fonts to Sign With

To configure the available fonts for the typing tab of the signing UI, use ElectronicSignatureOptions#setAvailableFonts. By default, four predefined fonts are bundled with the SDK. However, you can change, add, or remove these fonts however you like:

ElectronicSignatureOptions.setAvailableFonts(
    LinkedHashSet(
        listOf(
            Font("Caveat", ResourcesCompat.getFont(context, CAVEAT_FONT_RES)!!),
            Font("Pacifico", ResourcesCompat.getFont(context, PACIFICO_FONT_RES)!!)),
        )
    )
)
ElectronicSignatureOptions.setAvailableFonts(
    new LinkedHashSet<>(
        Arrays.asList(
            new Font("Caveat", Objects.requireNonNull(ResourcesCompat.getFont(context, CAVEAT_FONT_RES))),
            new Font("Pacifico", Objects.requireNonNull(ResourcesCompat.getFont(context, PACIFICO_FONT_RES))),
        )
    )
)