Documentation signoAPI Android - signotec GmbH

45
Documentation signoAPI Android Software components for Android for capturing signatures as well as for displaying and signing PDF documents signotec GmbH Am Gierath 20 b 40885 Ratingen, Germany (+49-2102) 53575-10 www.signotec.com [email protected] Version 2.3 as of 09.06.2021

Transcript of Documentation signoAPI Android - signotec GmbH

Page 1: Documentation signoAPI Android - signotec GmbH

Documentation signoAPI Android

Software components for Android for capturing signatures as well as for displaying and signing PDF documents

signotec GmbH

Am Gierath 20 b

40885 Ratingen, Germany

(+49-2102) 53575-10

www.signotec.com

[email protected]

Version 2.3 as of 09.06.2021

Page 2: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 2 of 45

Contents

1 DOCUMENT HISTORY 5

2 FUNCTIONAL OVERVIEW 6

3 SYSTEM REQUIREMENTS AND INTEGRATION 7

GENERAL INFORMATION 9

4 STSIGNOSIGNERCREATOR CLASS 10

CREATESIGNOVIEWER METHOD 10 RELEASESIGNOSIGNER METHOD 10

5 STSIGNOSIGNER CLASS 11

SETLICENSEKEY METHOD 11 SETSIGNATURETIMESTAMPFORMAT METHOD 11 SETTIMESTAMPCOLOR METHOD 12 LOADDOCUMENTFROMFILE METHOD 12 GETDOCUMENTMETADATA METHOD 12 SETCERTIFICATES METHOD 13 CREATENEWSIGNATUREFIELD METHOD 13 GETSIGNATUREINFO METHOD 14 GETDOCUMENTASFILE METHOD 14

SIGNSIGNATUREFIELD METHOD 14 SETSIGNATUREFIELDINFO METHOD 15

6 STSIGNOVIEWERCREATOR CLASS 16

CREATESIGNOVIEWER METHOD 16 RELEASESIGNOVIEWER METHOD 16

7 STSIGNOVIEWER CLASS 17

SETSIGNOVIEWERNOTIFIER METHOD 17 LOADDOCUMENTFROMFILE METHOD 17 SHOWTOOLBAR METHOD 18 SETTOOLBARHEIGHT METHOD 18 STARTSIGNATURE METHOD 19 GETFORMFIELDSINFO METHOD 19 SETFORMFIELDSINFO METHOD 20 CLOSEVIEWER METHOD 20 SETCUSTOMTHEME METHOD 20

SIGNDOCUMENT METHOD 21 CREATEVIEWERRECT METHOD 21 ENABLEAUTOROTATION METHOD 22 ENABLETOUCHEVENTS METHOD 22 ADDIMAGES METHOD 22 STARTTEXTSEARCH METHOD 23 FINISHTEXTSEARCH METHOD 24 SHOWPAGENUMBER METHOD 24

8 STSIGNOVIEWERNOTIFIER INTERFACE 25

DOCUMENTLOADED METHOD 25 WILLSTARTSIGNING METHOD 25 SIGNINGPROCESSSTARTED METHOD 26 SIGNINGPROCESSCONFIRMED METHOD 26 SIGNINGPROCESSCANCELLED METHOD 27

Page 3: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 3 of 45

SIGNINGPROCESSFAILED METHOD 27 SIGNATUREINFOPRESSED METHOD 28 DOCUMENTSAVED METHOD 28 BACKBUTTONPRESSED METHOD 29

VIEWERRECTCONFIRMED METHOD 29 VIEWERRECTCANCELLED METHOD 30

9 STSIGNOUTILS CLASS 31

APPENDPAGE METHOD 31 CREATEDOCUMENT METHOD 31 GETDOCUMENTMETADATAFROMFILE METHOD 32 GETFORMFIELDSINFOFROMFILE METHOD 32 SETFORMFIELDSINFOTOFILE METHOD 33 GETSIGNATUREINFOFROMFILE METHOD 33

10 STSIGNATUREFIELDINFODTO CLASS 34

11 STFORMFIELDINFODTO CLASS 35

12 STSIGNATURECAPTURECONFIG CLASS 36

13 STIMAGEDTO CLASS 37

14 STRECTDTO CLASS 38

15 STSIGNATURECAPTURECREATOR CLASS 39

CREATESIGNATURECAPTURE METHOD 39 RELEASESIGNATURECAPTURE METHOD 39

16 STSIGNATURECAPTURE CLASS 40

SETSIGNATURECAPTURENOTIFIER METHOD 40 CONFIGUREDIALOG METHOD 40 GETSIGNATUREIMAGE METHOD 41 GETSIGNDATA METHOD 41 SETLICENSEKEY METHOD 42 STARTSIGNATURECAPTURE METHOD 42 RESIZECAPTUREDIALOG METHOD 42

17 STSIGNATURECAPTURENOTIFIER INTERFACE 43

CAPTURINGCANCELLED METHOD 43 CAPTURINGCONFIRMED METHOD 43

18 STLOGGER CLASS 44

GETLOGGER METHOD 44

19 STVIEWERRECTDTO CLASS 45

Page 4: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 4 of 45

Legal notice

All rights reserved. This document and the components it describes are products copyrighted

by signotec GmbH, based in Ratingen, Germany. Software components developed by other

manufacturers are used in this product; legal information concerning these components is

listed in the folder entitled ‘3rd Party’. Reproduction of this documentation, in part or in whole,

is subject to prior written approval from signotec GmbH. All hardware and software names

used are trade names and/or trademarks of their respective manufacturers/owners. Subject

to change at any time without notice. We assume no liability for any errors that may appear in

this documentation.

Page 5: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 5 of 45

1 Document history

Version Date Person

responsible

Status/note

1.0 14 August

2018

Hasan Bas Document created

1.1 13

December

2018

Hasan Bas Changes in 3, 0 and 12

Sections 5.7, 7.9 9, 13 and 14 added

1.2 11 January

2019

Hasan Bas Changes in 2 and 3

Items 7.10 and 7.11 added

1.3 28 January

2019

Hasan Bas Changes in 2, 3, 4, 7, 8, 9, 10, 11, 12, 13,

14

Items 15, 16 and 17 added

1.4 7 March

2019

Hasan Bas Changes in 2, 3, 4, 7, 8.6 and 15

Items 4.2, 13.2 and 18 added

1.5 14 March

2019

Hasan Bas Changes in 3, 7.2 and 7.8

1.6 14 June

2019

Hasan Bas Changes in 3, 5 and 10

Items 5.4, 5.20, 5.21, 5.22, 5.23, 5.24,

5.25, 6.10, 6.11, 7.3, 7.4, 7.5, 7.6 and 17

added

1.7 14 August

2019

Hasan Bas Changes in 3, 10, 12 and 16.2

Items 5.11 and 16.7 added

1.8 5 December

2019

Hasan Bas Changes in 7.2 and 8.1

Item 3.1 added.

1.9 16

December

2019

Hasan Bas Changes in 7

2.0 17 February

2020

Hasan Bas Item 5.19 removed.

2.1 26 February

2020

Hasan Bas Changes in 12

Item 7.17 added.

2.2 3 July 2020 Hasan Bas Items 4 and 5 added

Changes in 2, 3 and 7

2.3 29 July

2020

Hasan Bas Changes in 5

Page 6: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 6 of 45

2 Functional overview

The signoAPI Android consists of the two static libraries libSignoPdfSigner and

libSignoSignatureCapture.

The libSignoPdfSigner makes it possible for the display and ISO-compliant signing of PDF

documents to be integrated into a custom Android app. It supports documents that already

obtain DigSig fields as well as those that contain SGN keywords. If required, you can obtain

information about the correct way to create compatible PDF documents from your contact

person at signotec GmbH.

The libSignoPdfSigner library contains an Activity and a Fragment class, within which the

document can be displayed and edited, plus some utility classes. The library can also load a

document without displaying it and the signature fields of this document can be signed using

a signature dialogue. The library does not require any additional software and can be used

offline without limitations.

The libSignoSignatureCapture library makes it possible to integrate a signature dialog for

capturing signatures into a custom Android app. A captured signature can be returned either

as an image or in the biometric SignData format. If required, you can receive information

about the SignData format from your contact person at signotec GmbH.

Page 7: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 7 of 45

3 System requirements and integration

signoAPI Android is supported on Android devices with API 21 and higher, and is directed at

Android Q (API 29). It can be used on Android devices with the following ABIs (Application

Binary Interface): armeabi-v7a, arm64-v8a, x86_64 and x86. The devices with API 21 and

higher can be targeted by specifying minSdkVersion in the build.gradle of your app. Your

minSdkVersion, compileSdkVersion and targetSdkVersion can be specified in the build.gradle

as follows:

android {

compileSdkVersion 29

defaultConfig{

applicationId “com.demo.app”

minSdkVersion 21

targetSdkVersion 29

}

}

The UI of the library is currently only optimised for smartphones and Android tablets.

The signoAPI Android consists of two libraries that need to be used in a custom project:

The following files and classes are required to use the libSignoPdfSigner component (not all of

the classes are required, depending on which functionality is used):

Android library as AAR file libSignoPdfSigner_x.x.x.aar

STSignoViewerCreator class

STSignoViewer class

STSignoSignerCreator class

STSignoSigner class

STSignoViewerNotifier interface

STSignatureFieldInfoDTO class

STFormFieldInfoDTO class

STSignatureCaptureConfig class

STImageDTO class

STRectDTO class

STSignoUtils class

STSignatureCaptureCreator class

STSignatureCapture class

STSignatureCaptureException class

STSignoViewerException class

STSignoSignerException class

STLogger class

STViewerRectDTO class

STSignatureCaptureNotifier interface

The most important class STSignoViewer can be used as a Fragment class in an Activity class.

For further information, see also the STSignoViewerCreator createSignoViewer() method.

In this case, the android:configChanges attribute of the respective <activity> element should

be edited in the Manifest file to specify that this Activity class carries out the following

configuration changes.

Page 8: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 8 of 45

<activity

android:name="com.demo.app.DemoActivity"

android:configChanges="orientation|keyboard|keyboardHidden|screenSize">

</activity>

The libSignoPdfSigner library can be integrated into your app as a new module with the

Assistant in Android Studio, and specified as a dependency within the build.gradle file of your

app:

dependencies {

...

implementation project(‘:libSignoPdfSigner_x.x.x’)

}

The following files and classes are required to use the libSignoSignatureCapture component

(not all of the classes are required, depending on which functionality is used):

Android library as AAR file libSignoSignatureCapture_x.x.x.a

STSignatureCaptureCreator class

STSignatureCapture class

STSignatureCaptureNotifier interface

STSignatureCaptureConfig class

The libSignoSignatureCapture library can be integrated into your app as a new module with

the Assistant in Android Studio, and specified as a dependency within the build.gradle file of

your app:

dependencies {

...

implementation project(‘:libSignoSignatureCapture_x.x.x’)

}

The images required for the user interface exist in the library. To replace the existing images

with your own images, you must create your own images in the respective ‘drawable’ folders

in your app. The dimensions and file names of the custom images must correspond to those of

the existing images.

The following images in the libSignoPdfSigner library can be replaced with your own images:

signoapi_capture_confirm.png

signoapi_capture_cancel.png

signoapi_capture_retry.png

signoapi_toolbar_back.png

signoapi_toolbar_back_pressed.png

signoapi_toolbar_logo.png

signoapi_toolbar_sign.png

signoapi_toolbar_sign_pressed.png

signoapi_toolbar_sign_summary.png

signoapi_toolbar_sign_summary_pressed.png

signoapi_toolbar_save.png

signoapi_toolbar_save_pressed.png

signoapi_sign_dialog.png

signoapi_signinfo_cancel.png

The following images in the libSignoSignatureCapture library can be replaced with your own

images:

Page 9: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 9 of 45

signoapi_capture_confirm.png

signoapi_capture_cancel.png

signoapi_capture_retry.png

signoapi_sign_dialog.png

General Information

The coordinates always refer to the coordinate system of a PDF. A PDF basically has the

resolution of 72 dpi and the point 0/0 is on the top left.

Page 10: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 10 of 45

4 STSignoSignerCreator class

The STSignoSignerCreator class is responsible for the creation of an STSignoSigner object

and creates only one instance of the STSignoSigner class. The class is part of

libSignoPDFSigner.

public class STSignoSignerCreator

createSignoViewer method

This method can be used to create an instance of the STSignoSigner class.

public static STSignoSigner createSignoSigner (Context context) throws

STSignoSignerException;

Parameter Description Context context The context of an Activity class.

Return value Description STSignoSigner The instance of the STSignoSigner class.

Exception Description STSignoSignerException Is thrown if an error occurs when the STSignoSigner

instance is generated.

Usage:

try{

STSignoSigner signoSigner = STSignoSignerCreator.createSignoSigner(

context);

} catch{

//error handling

}

releaseSignoSigner method

This method can be used to release the generated instance of the STSignoSigner class.

public static void releaseSignoSigner();

Parameter Description - -

Return value Description - -

Usage:

STSignoSignerCreator.releaseSignoSigner();

Page 11: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 11 of 45

5 STSignoSigner class

The STSignoSigner class is a significant part of libSignoPDFSigner. This class is used to load

and edit PDF documents without displaying them and offers the option of signing the

signature fields. All properties and methods of this class can also be used with the

STSignoViewer class if the document should also be displayed.

Usage:

STSignoSigner signoSigner =

STSignoSignerCreator.createSignoSigner(context);

Some methods return an integer, which can be used to identify errors. The possible error

codes are listed in the table below:

Error code Description

-100 Unable to load the document.

-110 Unable to generate the signature field.

-111 The document could not be loaded because it contains functions that are

not currently supported.

-112 Unable to generate the signature field on the desired page.

-113 A form or signature field with the same name already exists.

-114 A new signature field cannot be created in a signed document.

-115 The signature field has already been signed.

-116 The coordinates of the signature field lie outside of the visible area.

-117 The document contains no signature fields.

-118 The document contains no signature field with the given name.

-119 A new signature process cannot be started because another one is already

active.

-190 A signature field with the given name does not exist in the document.

-191 The rectangle that defines the size and position of the signature field is

invalid.

setLicenseKey method

This method can be used to enable the libSignoPDFSigner component and, in so doing, to

remove the demo message. Please use the licence string that was given to you by your

contact at signotec.

void setLicenseKey(String licenseKey);

Parameter Description String licenseKey Licence string

Return value Description - -

Usage:

signoSigner.setLicenseKey("1234");

setSignatureTimeStampFormat method

This method can be used to set an instance of the DateFormat class. This makes it possible to

visually add a time stamp with the signature to the document. If no instance from this class is

Page 12: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 12 of 45

created and set, no time stamp is added to the document. It must be set before the

loadDocumentFromFile() method is called.

void setSignatureTimeStampFormat(DateFormat dateFormat);

Parameter Description DateFormat dateFormat The instance of the DateFormat class

Return value Description - -

Usage:

DateFormat dateFormat =

new SimpleDateFormat(("E, dd MMM yyyy HH:mm:ss z", Locale.getDefault();

signoSigner.setSignatureTimeStampFormat(dateformat);

setTimeStampColor method

This property allows the colour of the timestamp in the signature image to be configured. If

the property is not set, black is used by default.

void setTimeStampColor(int timeStampColor);

Parameter Description int timeStampColor Colour of the timestamp

Return value Description - -

Usage:

signoSigner.setTimeStampColor(Color.BLUE);

loadDocumentFromFile method

This method loads a PDF document and interprets any SGN keywords it may contain.

int loadDocumentFromFile(byte[] documentData);

Parameter Description byte[] documentData The document to be loaded, as a byte array.

Return value Description int 0 Method was executed successfully

< 0 An error occurred (see above).

Usage:

int ret = signoSigner.loadDocumentFromFile(documentData);

if (ret < 0) {

// error handling

}

getDocumentMetaData method

This method reads the document’s metadata.

Page 13: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 13 of 45

String getDocumentMetaData();

Parameter Description - -

Return value Description String ‘Metadata’ entry from the ‘Document Catalog’

Usage:

String metaData = signoSigner.getDocumentMetaData();

setCertificates method

This method allows the keys and certificates for encrypting the biometric data and for signing

the document to be passed.

void setCertificates:(byte[] signingCertificate, String signCertPassword,

byte[] biometricCertificate);

Parameter Description byte[]

signingCertificate PKCS#12 file as a byte array, with the private key and the

public certificate for signing the document. String

signCertPassword Password for PKCS#12 file. This is ignored if null is

passed for signingCertificate. byte[]

biometricCertificate X.509 certificate as a byte array, with the public key for

encrypting the biometrics.

Return value Description - -

Usage:

signoSigner.setCertificates.(signCertificate, @"Password"

bioCertificate);

createNewSignatureField method

This method generates a new, empty signature field.

int createNewSignatureField(STSignatureFieldInfoDTO signatureField);

Parameter Description STSignatureFieldInfoDTO

signatureField Object that contains the properties of the new field.

Return value Description int 0 Method was executed successfully

< 0 An error occurred (see above).

Usage:

int ret = signoSigner.createNewSignatureField(signatureField);

if (ret < 0) {

// error handling

}

Page 14: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 14 of 45

getSignatureInfo method

This method can be used to retrieve information about the signature fields contained within

the document.

List<STSignatureFieldInfoDTO> getSignatureInfo();

Parameter Description - -

Return value Description List<STSignatureFieldIn

foDTO> A list that has one STSignatureFieldInfoDTO object per

signature field, or null if the document does not contain

any signature fields.

Usage:

List<STSignatureFieldInfoDTO> signFields =

signoSigner.getSignatureInfo();

getDocumentAsFile method

This method returns the document in its current state.

byte[] getDocumentAsFile();

Parameter Description - -

Return value Description byte[] The document as a byte array

Usage:

byte[] document = signoSigner.getDocumentAsFile();

signSignatureField method

This method can be used to sign a specific signature field with a signature that was captured

separately. A signature consisting of the biometric data and the image of the signature may

be captured with the STSignatureCapture, for example.

int signSignatureField(String signatureFieldName, byte[] signData, byte[]

image);

Parameter Bedeutung String

signatureFieldName The name of the signature field that is to be signed; the

field must not be signed already. If the document does not

contain a field with this name, a new field will be inserted

on page 1 with the coordinates (0, 0, 0, 0). byte[] signData Byte array with the biometric data as returned by

STSignatureCapture getSignData(). byte[] image Byte array with the image of the signature as returned by

STSignatureCapture getSignatureImage().

Rückgabewert Bedeutung int 0 Method was executed successfully.

< 0 An error occurred (see also STSignoViewerNotifier signingProcessFailed().

Page 15: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 15 of 45

Usage:

byte[] signData = signoCapture.getSignData();

byte[] image = signoCapture.getSignatureImage(800, 600, Color.Blue, 5);

int ret = signoSigner.signSignatureField("test_signature", signData,

image);

if (ret < 0) {

// error handling

}

setSignatureFieldInfo method

This method can be used to add the signature details such as the location of the signature and

the signature reason to a digital signature. Usually, this method is called in the

STSignoViewerNotifier willStartSigning() method or before the STSignoSigner

signSignatureField() method.

void setSignatureFieldInfo(STSignatureFieldInfoDTO signatureFieldInfoDTO);

Parameter Description STSignatureFieldInfoDTO

signatureFieldInfoDTO STSignatureFieldInfoDTO object

Return value Description - -

Usage:

STSignatureFieldInfoDTO signFieldDTO = new STSignatureFieldInfoDTO(“My

Signature”, “My Location”, “My Reason”);

oder

STSignatureFieldInfoDTO signFieldDTO = new STSignatureFieldInfoDTO();

signFieldDTO.setName(“My Signature”);

signFieldDTO.setLocation(“My Location”);

signFieldDTO.setReason(“My Reason”);

signoSigner.setSignatureFieldInfo(signFieldDTO);

Page 16: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 16 of 45

6 STSignoViewerCreator class

The STSignoViewerCreator class is responsible for the creation of an STSignoViewer object

and creates only one instance of the STSignoViewer class. The class is part of

libSignoPDFSigner.

public class STSignoViewerCreator

createSignoViewer method

This method can be used to create an instance of the STSignoViewer class.

public static STSignoViewer createSignoViewer(Context context, boolean

useAsFragment) throws STSignoViewerException;

Parameter Description Context context The context of an Activity class. boolean useAsFragment true The generated STSignoViewer instance can be

used as a Fragment instance.

false The generated STSignoViewer instance is the

instance of a Wrapper class for using the Activity

class.

Return value Description STSignoViewer The instance of the STSignoViewer class.

Exception Description STSignoViewerException Is thrown if an error occurs when the STSignoViewer

instance is generated.

Usage:

try{

STSignoViewer signoViewer = STSignoViewerCreator.createSignoViewer(

context, true);

} catch{

//error handling

}

releaseSignoViewer method

This method can be used to release the generated instance of the STSignoViewer class.

public static void releaseSignoViewer();

Parameter Description - -

Return value Description - -

Usage:

STSignoViewerCreator.releaseSignoViewer();

Page 17: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 17 of 45

7 STSignoViewer class

The STSignoViewer class is the core of the libSignoPDFSigner. This class is used for displaying

and editing PDF documents. The STSignoViewer can load and display PDF documents.

Gestures can be used to zoom and scroll, to fill in form fields and to add signatures to

signature fields. All methods of the STSignoSigner class also belong to the STSignoViewer

class. Only the additionally contained properties and methods are listed below.

Usage:

STSignoViewer signoViewer =

STSignoViewerCreator.createSignoViewer(context, true);

Some methods return an integer, which can be used to identify errors. The possible error

codes are listed in the table below:

Error code Description

-107 Unable to generate the toolbar as the Activity already has an action bar.

To use a toolbar instead, windowActionBar in Theme must be set to

false.

-138 Unable to start the signature capture process as no instance of the

STSignatureCaptureConfig class has been returned as a return value

from the STSignoViewerNotifier.willStartSigning() method.

-160 Unable to find an image to insert.

-161 Unable to insert the image.

-162 The size of the image is not permitted.

-163 Unable to insert the image on the required page.

-164 The image data is invalid or the format of the image is not supported.

-165 The coordinates of the image lie outside of the visible area.

-166 A new image cannot be inserted into a signed document.

-167 A transparent image cannot be inserted into a PDF/A-compliant document.

setSignoViewerNotifier method

This method can be used to set the instance that implements the STSignoViewerNotifier

class and is therefore to be informed of events in the STSignoViewer.

void setSignoViewerNotifier(STSignoViewerNotifier signoViewerNotifier);

Parameter Description STSignoViewerNotifier

signoViewerNotifier STSignoViewerNotifier instance

Return value Description - -

Usage:

STSignoViewerNotifier signoViewerNotifier =

new STSignoViewerNotifierImpl();

signoViewer.setSignoViewerNotifier(signoViewerNotifier);

loadDocumentFromFile method

This method starts asynchronous loading and viewing of a PDF document. Then the method

STSignoViewerNotifier.documentLoaded() is called and the result of this method can be

Page 18: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 18 of 45

obtained. When the document successfully loaded, the methods that make changes to the

document can be executed within the STSignoViewerNotifier.documentLoaded() method.

For further information, see also the STSignoViewerNotifier.documentLoaded() method.

If the STSignoViewer instance has been generated as a Fragment instance, this method is

only responsible for loading the PDF document. The FragmentTransaction.show() method

must be used to display the PDF document. For further information, see also the

STSignoViewerCreator.createSignoViewer() method.

void loadDocumentFromFile(byte[] documentData);

Parameter Description byte[] documentData The document to be loaded, as a byte array.

Return value Description - -

Usage:

signoViewer.loadDocumentFromFile(documentData);

signoViewer.loadDocumentFromFile(documentData);

FragmentTransaction ft = fragmentManager.beginTransaction();

ft.add(R.id.docLayout, signoViewer).show(signoViewer).commit();

showToolbar method

This method can be used to define whether or not the toolbar is to be displayed. It must be

set before the loadDocumentFromFile() method is called.

The toolbar currently contains the following four buttons:

‘Back’: Calls the STSignoViewerNotifier backButtonPressed() method.

‘Sign’: Jumps to the signature fields, in sequence.

‘Signature fields’: Calls the STSignoViewerNotifier signatureInfoPressed()

method and displays a dialog with the document’s signature fields, if there are any.

‘Save’: Calls the STSignoViewerNotifier documentSaved() method.

void showToolbar(boolean show);

Parameter Description boolean show true The toolbar is displayed.

false The toolbar is not displayed.

Return value Description - -

Usage:

signoViewer.showToolbar(true);

setToolbarHeight method

This method can be used to set the height of the toolbar and thus also sets the upper border

of the document viewer. The elements of the toolbar are always displayed at the toolbar’s

upper edge. It must be set before the loadDocumentFromFile() method is called.

Page 19: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 19 of 45

void setToolbarHeight(int toolbarHeight);

Parameter Description int toolbarHeight The height of the toolbar.

Return value Description - -

Usage:

signoViewer.setToolbarHeight(120);

startSignature method

This method begins the process of capturing signatures. This functionality can also be

triggered via the ‘sign’ button in the toolbar or by touching a signature field in the document.

int startSignature();

int startSignature(String signatureFieldName);

Parameter Description String

signatureFieldName (Optional) The name of the signature field that needs to be

signed; in cases where no name is passed, the interface

will jump to each field in the document one at a time,

following the sequence in which the fields were inserted

into the document.

Return value Description int 0 Method was executed successfully

< 0 An error occurred (see above).

Usage:

int ret = signoViewer.startSignature(“customer_signature”);

if (ret < 0) {

// error handling

}

getFormFieldsInfo method

This method can be used to retrieve information about the form fields contained within the

document.

List<STFormFieldInfoDTO> getFormFieldsInfo();

Parameter Description - -

Return value Description List<STFormFieldInfoDT

O> A list that has one STFormFieldInfoDTO object per form

field, or null if the document does not contain any form

fields.

Usage:

List<STFormFieldInfoDTO> formFields = signoViewer.getFormFieldsInfo();

Page 20: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 20 of 45

setFormFieldsInfo method

This method can be used to change the content and ‘read only’ property of form fields.

void setFormFieldsInfo(List<STFormFieldInfoDTO> fields);

Parameter Description List<STFormFieldInfoDT

O> Form fields, whose properties are to be changed, as a list

of STFormFieldInfoDTO objects. Only the name, value and

readOnly properties of the objects are currently evaluated.

Return value Description - -

Usage:

List<STFormFieldInfoDTO> formFields = signoViewer.getFormFieldsInfo();

for (STFormFieldInfo formField : formFields) {

if (formField.name.equals("MyField")) {

formFields.value = "My value";

formField.readOnly = true;

}

}

signoViewer.setFormFieldsInfo.(formFields);

closeViewer method

This method can be used to remove the view and switch back to the custom app interface.

If the STSignoViewer instance has been generated as a Fragment instance, the view can also

be removed with the FragmentTransaction.remove() method. For further information, see

also the STSignoViewerCreator.createSignoViewer() method.

void closeViewer();

Parameter Description - -

Return value Description - -

Usage:

signoViewer.closeViewer();

FragmentTransaction ft = fragmentManager.beginTransaction();

ft.remove(signoViewer).commit();

setCustomTheme method

This method can be used to replace the standard design of the toolbar with a user-defined

design. The Activity class in the API is based on the Android Compatibility Library v7, which

means that the user-defined design must be inherited from Theme.AppCombat. In the user-

defined design, the primary colours can be defined with the colorPrimary, colorAccent and

colorPrimaryDark attributes, and the standard action bar of the window decor must be

manually disabled by setting windowActionBar to false and windowNoTitle to true.

Page 21: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 21 of 45

void setCustomTheme(int customTheme);

Parameter Description int customTheme Value of the Theme

Return value Description - -

Usage:

<style name="SignoApiTheme" parent="Theme.AppCompat.Light">

<item name="colorPrimary">@color/colorPrimary</item>

<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

<item name="colorAccent">@color/colorAccent</item>

<item name="windowActionBar">false</item>

<item name="windowNoTitle">true</item>

</style>

signoViewer.setCustomTheme(R.style.SignoApiTheme);

signDocument method

This method can be used to add a digital signature to the document without the need for a

signature capture process.

int signDocument(String signatureFieldName);

Parameter Description String

signatureFieldName The name of the signature field that is to be signed; the

field must not be signed already. If the document does not

contain a field with this name, a new field will be inserted

on page 1 with the coordinates (0, 0, 0, 0).

Return value Description int 0 Method was executed successfully

< 0 An error occurred (see also signingProcessFailed()).

Usage:

int ret = signoViewer.signDocument("final_doc_signature");

if (ret < 0) {

// error handling

}

createViewerRect method

This method can be used to display a rectangle on the PDF viewer whose size and position can

be modified by the user. Two buttons for cancelling and confirming are also generated in

addition to the rectangle. Tapping the cancel button calls the

STSignoViewerNotifier.viewerRectCancelled() method. Tapping the confirmation button

calls the STSignoViewerNotifier.viewerRectConfirmed() method. Further rectangle

properties can be configured using the STViewerRectDTO class. For further information, see

also the STViewerRectDTO class.

Page 22: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 22 of 45

int createViewerRect(STViewerRectDTO viewerRectDTO);

Parameter Description STViewerRectDTO

viewerRectDTO The STViewerRectDTO object.

Return value Description int > 0 Unique ID of the generated rectangle.

-1 An error occurred.

Usage:

STViewerRectDTO rectViewerDTO = new STViewerRectDTO();

int rectViewId = signoViewer.createViewerRect(rectViewerDTO);

enableAutoRotation method

This method allows the rotation of the screen to be enabled and disabled.

void enableAutoRotation(boolean enabled);

Parameter Description boolean enabled true Screen rotation is enabled.

false Screen rotation is disabled.

Return value Description - -

Usage:

signoViewer.enableAutoRotation(true);

enableTouchEvents method

This method allows all touch events in the PDF viewer to be enabled and disabled.

void enableTouchEvents(boolean enabled);

Parameter Description boolean enabled true All touch events are enabled.

false All touch events are disabled.

Return value Description - -

Usage:

signoViewer.enableTouchEvents(true);

addImages method

This method can be used to insert images into the loaded document.

int addImages(List<STImageDTO> images);

Parameter Description List<STImageDTO>

images A list of STImageDTO objects. May be null, in which case

no images are added.

Page 23: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 23 of 45

Return value Description int 0 Method was executed successfully

< 0 An error occurred (see above).

Usage:

STRectDTO size = new STRectDTO();

size.setUnit(STRectDTO.Unit.UnitMillimetres);

size.setRectangle(new RectF(0.0f, 0.0f, 210.0f, 297.0f));

STImageDTO imageDTO = new STImageDTO();

Bitmap myimage = BitmapFactory.decodeResource(this.getResources(),

R.drawable.myimage);

imageDTO.setImage(myimage);

imageDTO.setRectDTO(size);

imageDTO.setPage(1);

List<STImageDTO> images = new ArrayList<>();

images.add(imageDTO);

int result = signoViewer.addImages(images);

startTextSearch method

This method searches for text on a PDF page, visually highlights all the places where the text

was found (if applicable) and returns the positions of all these places.

List<Rect> startTextSearch(String text, int page, int highlightColor, boolean

onlyWholeWord, boolean caseSensitive);

Parameter Description String text Text to search for. int page Page on which to search for the text. The first page

number of the document starts with 1. int highlightColor Background colour of the rectangle that visually highlights

the search text found in the PDF viewer. If 0 is passed, no

highlighting is shown. boolean onlyWholeWord true Only finds whole words.

false Finds all occurrences. boolean caseSensitive true The search is case-sensitive.

false The search is not case-sensitive.

Return value Description List The positions of all the places where the text was found as

a list of Rect objects or an empty list.

Usage:

List<Rect> foundedTextPositions =

signoViewer.startTextSearch(“Signature”, 1, null, true, true);

for(Rect rect : foundedTextPositions){

SignatureFieldInfoDTO field = new SignatureFieldInfoDTO();

field.setName(“@New_Signature”);

field.setPage(1);

field.setRectangle(rect);

int result = signoViewer.createNewSigantureField(field);

}

Page 24: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 24 of 45

finishTextSearch method

This method can be used to remove the visual highlights, which are displayed at all places

where the search text was found after calling the STSignoViewer startTextSearch()

method, from the PDF viewer.

void finishTextSearch();

Parameter Description - -

Return value Description - -

Usage:

signoViewer.finishTextSearch();

showPageNumber method

This method can be used to determine whether the page number is displayed on the PDF

viewer.

void showPageNumber(boolean show);

Parameter Description boolean show true The page number is displayed.

false The page number is not displayed.

Return value Description - -

Usage:

signoViewer.showPageNumber(true);

Page 25: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 25 of 45

8 STSignoViewerNotifier interface

The STSignoViewerNotifier interface contains methods that are called when certain events

from the STSignoViewer classes take place. This class must be implemented by a class. The

instance of this class should be set with the STSignoViewer setSignoViewerNotifier()

method. The class is part of libSignoPDFSigner.

public interface STSignoViewerNotifier

public class STSignoViewerNotifierImpl implements STSignoViewerNotifier

Usage:

STSignoViewerNotifier signoViewerNotifier = new

STSignoViewerNotfierImpl();

signoViewer.setSignoViewerNotifier(signoViewerNotifier);

documentLoaded method

This method is called at the end of the asynchronous STSignoViewer

loadDocumentFromFile() method. When the document successfully loaded, the methods that

make changes to the document can be executed within this method. (For example, adding

signature fields using the STSignoViewer createNewSignatureField() method).

void documentLoaded(int resultCode);

Parameter Description int resultCode 0 The STSignoViewer loadDocumentFromFile()

method was executed successfully < 0 An error occurred (see above).

Return value Description - -

Usage:

void documentLoaded(int resultCode)

{

// event handling

}

willStartSigning method

This method is called whenever the signature capture needs to be initiated for a signature

field that has not yet been signed.

STSignatureCaptureConfig willStartSigning(String signatureFieldName);

Parameter Description String signatureFieldName Name of the signature field for which the signature

needs to be captured.

Return value Description STSignatureCaptureConfig !=

null The signature capture needs to be initiated with

the properties that are set in the returned

instance. null The signature capture should not be initiated.

Page 26: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 26 of 45

Usage:

STSignatureCaptureConfig willStartSigning(String signatureFieldName)

{

STSignatureCaptureConfig config = new STSignatureCaptureConfig();

config.setSignatureColor(Color.BLUE);

config.setLineWidth(10);

config.setFont(TypeFace.create(“Arial”, TypeFace.Bold_ITALIC));

config.setDisplayText(signatureFieldName);

config.setFontSize(40);

config.setTextColor(Color.BLACK);

config.setPosition(new Rect(0,0,1000,100));

return config;

}

signingProcessStarted method

This method is called if the signature capture is initiated for a signature field that has not yet

been signed.

List<STFormFieldInfoDTO> signingProcessStarted(String signatureFieldName);

Parameter Description String

signatureFieldName Name of the signature field for which the signature is being

captured.

Return value Description List<STFormFieldInfoDT

O> Reserved for future use.

Usage:

List<STFormFieldInfoDTO> signingProcessStarted(String signatureFieldName)

{

return null;

}

signingProcessConfirmed method

This method is called whenever the signature capture for a signature field has successfully

ended and there is a signed document.

void signingProcessConfirmed(String signatureFieldName);

Parameter Description String

signatureFieldName Name of the signature field for which the signature has

been captured.

Return value Description - -

Usage:

void signingProcessConfirmed(String signatureFieldName)

{

// event handling

}

Page 27: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 27 of 45

signingProcessCancelled method

This method is called if the signature capture process has been aborted by the user (with the

‘Cancel’ button).

void signingProcessCancelled(String signatureFieldName);

Parameter Description String

signatureFieldName Name of the signature field for which the capture process

has been aborted.

Return value Description - -

Usage:

void signingProcessCancelled(String signatureFieldName)

{

// event handling

}

signingProcessFailed method

This method is called if the signature capture process or signature insertion into the document

failed.

void signingProcessFailed(String signatureFieldName, String errorMessage,

String errorCode);

Parameter Description String

signatureFieldName Name of the signature field for which the capture process

failed. String errorMessage Description of the error String errorCode Error code.

Return value Description - -

Usage:

void signingProcessFailed(String signatureFieldName, String errorMessage,

String errorCode)

{

// event handling

}

Page 28: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 28 of 45

The following errors may occur:

Error code Description

-108 Unable to start the signature process.

-120 Unable to load the document.

-121 Unable to read the document.

-122 The PDF is password protected.

-123 Unable to find the key container.

-124 Unable to read the key container.

-125 The key container password is invalid.

-126 The format of the key container is not supported.

-127 The key container does not contain a private key.

-128 Error when writing the file.

-129 Error when signing the document.

-130 Invalid signature field name.

-131 Unable to read the certificate.

-132 The captured signature is too short.

-135 No private key/certificate was passed before the document was signed.

-137 An error occurred while creating the signature image.

signatureInfoPressed method

This method is called if the ‘signature field’ button in the toolbar has been touched.

boolean signatureInfoPressed();

Parameter Description - -

Return value Description boolean true The library displays the standard dialog with the

signature fields of the document. false The library no longer reacts to the event; the app

then typically carries out the event handling.

Usage:

boolean signatureInfoPressed

{

return true;

}

documentSaved method

This method is called if the ‘save’ button in the toolbar has been touched. Usually, in this

event, the STSignoViewer getDocumentAsFile() method should be called.

boolean documentSaved();

Parameter Description - -

Return value Description boolean true The ‘Save’ button needs to be greyed out.

false The ‘Save’ button should not be greyed out.

Page 29: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 29 of 45

Usage:

boolean documentSaved()

{

// event handling

return true;

}

backButtonPressed method

This method is called if the ‘back’ button in the toolbar has been touched. Usually, the

STSignoViewer closeViewer() method should be called. For further information, see also

the STSignoViewer closeViewer() method.

void backButtonPressed()

Parameter Description - -

Return value Description - -

Usage:

void backButtonPressed()

{

// event handling

}

viewerRectConfirmed method

This method is called if the confirm button of a rectangle generated by calling

STSignoViewer.createViewerRect() is tapped. Usually, in this event,

STSignoViewer.createNewSignatureField() or STSignoViewer.addImages() should be

called.

boolean viewerRectConfirmed(Rect rectInPdf, int page, int viewerRectId);

Parameter Description Rect rectInPdf Position and size of the rectangle on the page in the

coordinate system of a PDF. int page Number of the page on which the rectangle was confirmed.

The first page number of the document starts with 1. Int viewerRectId Unique ID of the generated rectangle.

Return value Description boolean true The rectangle should be hidden.

false The rectangle should continue to be displayed.

Page 30: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 30 of 45

Usage:

boolean viewerRectConfirmed(Rect rectInPdf, int page, int viewerRectId

{

STSignatureFieldInfoDTO sigField = new STSignatureFieldInfoDTO();

sigField.setName("New_Signature");

sigField.setPage(page);

sigField.setRectangle(rectInPdf);

int result = signoViewer.createNewSignatureField(sigField);

if (result < 0)

// error handling

return false;

return true;

}

viewerRectCancelled method

This method is called if the cancel button of a rectangle generated by calling

STSignoViewer.createViewerRect() is tapped.

void viewerRectCancelled(int viewerRectId);

Parameter Description int viewerRectId Unique ID of the generated rectangle.

Return value Description - -

Usage:

void viewerRectCancelled(int viewerRectId)

{

//error handling

}

Page 31: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 31 of 45

9 STSignoUtils class

The STSignoUtils class is a Utility class in the libSignoPDFSigner and consists of static

methods. This class can be used to edit the PDF documents and to create new PDF documents

without displaying them. The class is part of libSignoPDFSigner.

appendPage method

This method can be used to append an empty page to a document and to insert images on

this page (optional).

public static byte[] appendPage(STRectDTO size, byte[] document,

List<STImageDTO> images);

Parameter Description STRectDTO size The size of the new page. byte[] document The document as a byte array. List<STImageDTO>

images A list of STImageDTO objects. May be null, in which case

no images are added.

Return value Description byte[] The changed document as a byte array.

Usage:

STRectDTO size = new STRectDTO();

size.setUnit(STRectDTO.Unit. UnitMillimetres);

size.setRectangle(new RectF(0.0f, 0.0f, 210.0f, 297.0f));

STImageDTO imageDTO = new STImageDTO();

Bitmap myimage = BitmapFactory.decodeResource(this.getResources(),

R.drawable.myimage);

imageDTO.setImage(myimage);

imageDTO.setRectDTO(size);

List<STImageDTO> images = new ArrayList<>(); images.add(imageDTO);

byte[] changedDoc = STSignoUtils.appendPage(size, document, images);

createDocument method

This method can be used to generate a document from empty pages and insert images on the

pages (optional).

public static byte[] createDocument(STRectDTO size, int pages, PdfACompliance

compliance, List<STImageDTO> images);

Parameter Description STRectDTO size The size of the new page. int pages The number of pages. PdfACompliance

compliance PDF/A Compliance

List<STImageDTO>

images A list of STImageDTO objects. May be null, in which case

no images are added.

Return value Description byte[] The changed document as a byte array.

The PdfACompliance enumeration is defined in the STSignoUtils class as follows:

Page 32: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 32 of 45

public enum PdfACompliance

{

None,

PdfA1b,

PdfA3b

}

Value Description None No PDF/A Compliance PdfA1b PDF/A1b Compliance PdfA3b PDF/A3b Compliance

Usage:

STRectDTO size = new STRectDTO();

size.setUnit(STRectDTO.Unit.UnitMillimetres);

size.setRectangle(new RectF(0.0f, 0.0f, 210.0f, 297.0f));

STImageDTO imageDTO = new STImageDTO();

Bitmap myimage = BitmapFactory.decodeResource(this.getResources(),

R.drawable.myimage);

imageDTO.setImage(myimage);

imageDTO.setRectDTO(size);

List<STImageDTO> images = new ArrayList<>(); images.add(imageDTO);

byte[] createdDoc = STSignoUtils.createDocument(size, 1,

STSignoUtils.PdfACompliance.None, images);

getDocumentMetaDataFromFile method

This method reads the document’s metadata without affecting any of the existing instances of

the STSignoViewer class.

public static String getDocumentMetaDataFromFile(byte[] document);

Parameter Description byte[] document The document as a byte array.

Return value Description String ‘Metadata’ entry from the ‘Document Catalog’

Usage:

String metaData = STSignoUtils.getDocumentMetaDataFromFile(document);

getFormFieldsInfoFromFile method

This method can be used to retrieve information about the form fields contained within the

document without affecting any of the existing instances of the STSignoViewer class.

public static List<STFormFieldInfoDTO> getFormFieldsInfoFromFile(byte[]

document);

Parameter Description byte[] document The document as a byte array.

Return value Description List<STFormFieldInfoDT

O> A list that has one STFormFieldInfoDTO object per form

field, or null if the document does not contain any form

fields.

Page 33: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 33 of 45

Usage:

List<STFormFieldInfoDTO> formFields =

STSignoUtils.getFormFieldsInfoFromFile(document);

setFormFieldsInfoToFile method

This method can be used to change the content and ‘read only’ property of form fields.

public static byte[] setFormFieldsInfoToFile(List<STFormFieldInfoDTO>

formFieldsInfo, byte[] document);

Parameter Description List<STFormFieldInfoDT

O> formFieldsInfo Form fields, whose properties are to be changed, as a list

of STFormFieldInfoDTO objects. Only the name, value and

readOnly properties of the objects are currently evaluated. byte[] document The document as a byte array.

Return value Description byte[] The changed document as a byte array.

Usage:

List<STFormFieldInfoDTO> formFields =

STSignoUtils.getFormFieldsInfoFromFile(document);

for (STFormFieldInfo formField : formFields) {

if (formField.getName().equals("MyField")) {

formFields.setValue("My value");

formField.setReadOnly(true);

}

}

byte[] changedDoc = STSignoUtils.setFormFieldsInfo(formFields, document);

getSignatureInfoFromFile method

This method can be used to retrieve information about the signature fields contained within

the document without affecting any of the existing instances of the STSignoViewer class.

public static List<STSignatureFieldInfoDTO> getSignatureInfoFromFile(byte[]

document);

Parameter Description byte[] document The document as a byte array.

Return value Description List<STSignatureFieldI

nfoDTO> A list that has one STSignatureFieldInfoDTO object per

signature field, or null if the document does not contain

any signature fields.

Usage:

List<STSignatureFieldInfoDTO> sigFields =

STSignoUtils.getSignatureInfoFromFile(document);

Page 34: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 34 of 45

10 STSignatureFieldInfoDTO class

The STSignatureFieldInfoDTO class is a data object that contains the properties of a

signature field. The class is part of libSignoPDFSigner.

Property Description String name Name of the signature field Rect rectangle Position specification of the signature field int page Page on which the signature field is located. The first

page number of the document starts with 1. boolean isSigned true if the field has already been signed, otherwise

false boolean isRequired true if the field is a mandatory field, otherwise false String location Location of the signature String reason Reason of the signature

Page 35: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 35 of 45

11 STFormFieldInfoDTO class

The STFormFieldInfoDTO class is a data object that contains the properties of a form field.

The class is part of libSignoPDFSigner.

Property Description String name Name of the form field Rect rectangle Position specification of the form field int page Page on which the form field is located. The first

page number of the document starts with 1. FormFieldType type Type of form field String value Value of the form field boolean readOnly ‘Read only’ property of the form field boolean isRequired true if the field is a mandatory field, otherwise false

Page 36: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 36 of 45

12 STSignatureCaptureConfig class

The STSignatureCaptureConfig class is a data object that contains the configuration

properties for the signature dialog. For further information, see also the method

STSignoViewerNotifier.willStartSigning() or

STSignatureCapture.configureDialog().The class is part of libSignoPDFSigner as well as

part of libSignoSignatureCapture.

Property Description String displayText Text displayed in the signature dialog Typeface font Font and style of the text in the signature dialog int fontSize Font size of the text in the signature dialog (in dp) Int textColor Colour of the text in the signature dialog Rect position Position specification of the text in the signature

dialog int signatureColor Pen colour of the signature int lineWidth Pen width of the signature in dp (1–20) boolean

enablePressureDependentCaptu

ring

true The signature is displayed in the signature

dialog with pressure levels. false The signature is not displayed in the

signature dialog with pressure levels. boolean

enableFullScreenCapture

true The signature dialog is displayed in full

screen mode. false The signature dialog is displayed in standard

mode. boolean enableTouchSignature true Activates signature capture with a finger in

the signature dialog. false Deactivates signature capture with a finger

in the signature dialog. boolean

enablePencilSignature

true Activates signature capture with a pen in

the signature dialog. false Deactivates signature capture with a pen in

the signature dialog. boolean

enableBiometricDataCapturing

true Biometric data is captured. false No biometric data is captured.

dp = density-independent pixels

Page 37: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 37 of 45

13 STImageDTO class

The STImageDTO class is a data object that represents an image on a PDF page and its

position. The class is part of libSignoPDFSigner.

Property Description Bitmap image Image STRectDTO rectangle Position specification of the image within a PDF page int page Page specification of the image within a document.

The first page number of the document starts with 1.

Page 38: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 38 of 45

14 STRectDTO class

The STRectDTO class is a data object that represents a rectangle. The class is part of

libSignoPDFSigner.

Property Description RectF rectangle Position specification of the rectangle Unit unit Unit of measurement of the coordinates

The Unit enumeration is defined as follows:

public enum Unit{UnitPoints(0), UnitMilimetres(1), UnitInches(2);

Value Description UnitPoints The coordinates are given in points. A PDF document

essentially has a resolution of 72 dpi. UnitMillimetres The coordinates are given in millimetres. UnitInches The coordinates are given in inches.

Page 39: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 39 of 45

15 STSignatureCaptureCreator class

The STSignatureCaptureCreator class is responsible for the creation of an

STSignatureCapture object and creates only one instance of the STSignatureCapture class.

The class is part of libSignoPDFSigner as well as of libSignoSignatureCapture.

public class STSignatureCaptureCreator

createSignatureCapture method

This method can be used to create an instance of the STSignatureCapture class.

public static STSignatureCapture createSignatureCapture(Context context)

throws STSignatureCaptureException;

Parameter Description Context context The context of an Activity class

Return value Description STSignatureCapture The instance of the STSignatureCapture class.

Exception Description STSignatureCaptureExce

ption Is thrown if an error occurs when the STSignatureCapture

instance is generated.

Usage:

try{

STSignatureCapture signatureCapture =

STSignatureCaptureCreator.createSignatureCapture(context);

} catch {

//error handling

}

releaseSignatureCapture method

This method can be used to release the generated instance of the STSignatureCapture class.

public static void releaseSignatureCapture();

Parameter Description - -

Return value Description - -

Usage:

STSignoViewerCreator.releaseSignatureCapture();

Page 40: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 40 of 45

16 STSignatureCapture class

The STSignatureCapture class is the most important component of the

libSignoSignatureCapture library. This class can be used to display a dialog to capture a

signature. The class is part of libSignoPDFSigner as well as of libSignoSignatureCapture.

Usage:

STSignatureCapture signatureCapture =

STSignatureCaptureCreator.createSignatureCapture(context);

setSignatureCaptureNotifier method

This method can be used to set the instance that implements the

STSignatureCaptureNotifier class and is therefore to be informed of events in the

STSignatureCapture.

void setSignatureCaptureNotifier(STSignatureCaptureNotifier

signatureCaptureNotifier);

Parameter Description STSignatureCaptureNotifier

signatureCaptureNotifier STSignatureCaptureNotifier instance

Return value Description - -

Usage:

STSignatureCaptureNotifier signatureCaptureNotifier =

new STSignatureCaptureNotifierImpl();

signatureCapture.setSignatureCaptureNotifier(signatureCaptureNotifier);

configureDialog method

This method can be used to position and configure the signature dialog. The configuration is

ignored if the enableFullScreenCapture property of the STSignatureCaptureConfig class is

set to true.

void configureDialog(Rect dialogFrame, STSignatureCaptureConfig

captureConfig);

Parameter Description Rect dialogFrame Position specification of the signature dialog. STSignatureCaptureConfig

captureConfig The STSignatureCaptureConfig object or null.

Return value Description - -

Page 41: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 41 of 45

Usage:

STSignatureCaptureConfig captureConfig = new STSignatureCaptureConfig();

captureConfig.setSignatureColor(Color.BLUE);

captureConfig.setLineWidth(10);

captureConfig.setFont(TypeFace.create(“Arial”, TypeFace.Bold_ITALIC));

captureConfig.setDisplayText(signatureFieldName);

captureConfig.setFontSize(40);

captureConfig.setTextColor(Color.BLACK);

captureConfig.setPosition(new Rect(0,0,1000,100));

Rect rect = new Rect(0, 0, 700, 500);

signatureCapture.configureDialog(rect, captureConfig);

getSignatureImage method

This method returns the most recently captured signature as an image in PNG format.

byte[] getSignautureImage(float width, float height, int penColor, int

penWidth) throws STSignatureCaptureException;

Parameter Description float width Maximum width of the image in pixels. float height Maximum height of the image in pixels. int penColor Colour of the signature line. int penWidth Width of the signature line in pixels.

Return value Description byte[] The signature image as a byte array or null.

Exception Description STSignatureCaptureExce

ption Is thrown if an error occurs when the signature image is

generated.

Usage:

try{

byte[] signatureImage =

signatureCapture.getSignatureImage(1500, 1000, Color.BLUE, 10);

} catch (STSignatureCaptureException e){

//error handling

}

getSignData method

This method returns the most recently captured signature in SignData format.

byte[] getSignData();

Parameter Description - -

Return value Description byte[] The SignData as a byte array or null.

Usage:

byte[] signData = signatureCapture.getSignData();

Page 42: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 42 of 45

setLicenseKey method

This method can be used to enable the libSignoSignatureCapture component and, in so doing,

to remove the demo message. Please use the licence string that was given to you by your

contact at signotec.

void setLicenseKey(String licenseKey);

Parameter Description String licenseKey Licence string

Return value Description - -

Usage:

signatureCapture.setLicenseKey("1234");

startSignatureCapture method

This method can be used to start the signature capture process.

void startSignatureCapture();

Parameter Description - -

Return value Description - -

Usage:

signatureCapture.startSignatureCapture();

resizeCaptureDialog method

This method can be used to change the size and position of the signature dialog according to

the new configuration of the signature dialog by the configureDialog() method while

rotating the device. Usually, this method is called in the onConfigurationChanged() method

of the respective Activity class.

void resizeCaptureDialog();

Parameter Description - -

Return value Description - -

Usage:

signatureCapture.resizeCaptureDialog();

Page 43: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 43 of 45

17 STSignatureCaptureNotifier interface

The STSignatureCaptureNotifier interface contains methods that are called for specific

events from the STSignatureCapture class. This interface must be implemented by a class.

The instance of this class must be set with the STSignatureCapture

setSignatureCaptureNotifier() method. The interface is part of libSignoPDFSigner as well

as of libSignoSignatureCapture.

public interface STSignatureCaptureNotifier

public class STSignatureCaptureNotifierImpl implements

STSignatureCaptureNotifier

Usage:

STSignatureCaptureNotifier signatureCaptureNotifier = new

STSignatureCaptureNotifierImpl();

signatureCapture.setSignatureCaptureNotifier(signatureCaptureNotifier);

capturingCancelled method

This method is called if the signature capture process has been aborted by the user.

void capturingCancelled();

Parameter Description - -

Return value Description - -

Usage:

void capturingCancelled()

{

// event handling

}

capturingConfirmed method

This method is called if the signature capture process has been confirmed by the user.

void capturingConfirmed(int numberOfPoints);

Parameter Description int numberOfPoints Number of points captured.

Return value Description - -

Usage:

void capturingConfirmed(int numberOfPoints){

// event handling

}

Page 44: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 44 of 45

18 STLogger class

The STLogger class is used to activate and configure logging via the Java Logging API. The

class is part of libSignoPDFSigner as well as of libSignoSignatureCapture.

getLogger method

This method returns the Logger object generated in the API so that logging can be configured

outside of the API.

public static Logger getLogger();

Parameter Description - -

Return value Description Logger Logger object of the Java Logging API

Usage:

String logFilePath = Environment.getExternalStorageDirectory() + log.txt;

Logger logger = STLogger.getLogger();

logger.setLevel(Level.ALL);

FileHandler fileTxt = null;

try {

fileTxt = new FileHandler(logFilePath);

} catch (IOException e) {

return;

}

// create a TXT formatter

SimpleFormatter formatterTxt = new SimpleFormatter();

fileTxt.setFormatter(formatterTxt);

logger.addHandler(fileTxt);

Page 45: Documentation signoAPI Android - signotec GmbH

© 2000 – 2021 signotec GmbH signoAPI Android Documentation Page 45 of 45

19 STViewerRectDTO class

The STViewerRectDTO class is a data object that represents a rectangle on the PDF viewer.

The class is part of libSignoPDFSigner.

Property Description Rect rectangle Position specification of the rectangle (default unit of

measurement in dp) int borderColor Border colour of the rectangle int backgroundColor Background colour of the rectangle Bitmap backgroundImage Background image of the rectangle

The position specification of the rectangle can be passed in two different units of

measurement. The STViewerRectUnit enumeration is used for this purpose. The

STViewerRectUnit enumeration is defined in the STViewerRectDTO class as follows:

public enum STViewerRectUnit

{

DP,

PX

}

Value Description DP Position specification of the rectangle in dp (density-independent

pixels). PX Position specification of the rectangle in pixels.

Usage:

STViewerRectDTO viewerRectDTO = new STViewerRectDTO();

viewerRectDTO.setRectangle(new Rect(10,10,100,100));

viewerRectDTO.setRectangle(new Rect(10,10,100,100),

STViewerRectDTO.STViewerRectUnit.PX);

viewerRectDTO.setRectangle(new Rect(10,10,100,100),

STViewerRectDTO.STViewerRectUnit.DP);