Breadcrumbs

signoAPI Android – STSignoViewerNotifier interface

The STSignoViewerNotifier interface contains methods that are called when certain events from the STSignoViewer class take place. This interface is derived from the interface STSignoSignerNotifier and must be implemented by a class. The instance of this class must be set with the STSignoViewer.setSignoViewerNotifier() method. The interface is part of libSignoPDFSigner.

Java
public interface STSignoViewerNotifier extends STSignoSignerNotifier
Java
public class STSignoViewerNotifierImpl implements STSignoViewerNotifier

Anwendung:

Java
public class STSignoViewerNotifierImpl implements STSignoViewerNotifier {

  public void documentLoaded(int resultCode) {
      // add your code here...
  }

  public STSignatureCaptureConfig willStartSigning(String signatureFieldName, STStartSigningCallback callback) {
      // add your code here...
  }

  public List<STFormFieldInfoDTO> signingProcessStarted(String signatureFieldName) {
      // add your code here...
  }

  public void signingProcessConfirmed(String signatureFieldName) {
      // add your code here...
  }

  public void signingProcessCancelled(String signatureFieldName) {
      // add your code here...
  }

  public void signingProcessFailed(String signatureFieldName, String errorMessage, String errorCode) {
      // add your code here...
  }
}

documentLoaded method

This method is called at the end of the asynchronous STSignoViewer.loadDocumentFromFile(). If it is successful, the changes can be made in the document. (For example, signature fields can be added using the method STSignoViewer.createNewSignatureField().)

Java
void documentLoaded(int resultCode);

Parameter

Description

int resultCode

0

STSignoViewer.loadDocumentFromFile() method was executed successfully

< 0

An error occurred (see above).

Return value

Description

-

-

Usage:

Java
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.

Java
void willStartSigning(String signatureFieldName, STStartSigningCallback startSigningCallback);

Parameter

Description

String signatureFieldName

Name of the signature field for which the signature needs to be captured.

STStartSigningCallback

Instance of the STStartSigningCallback callback interface

Return value

Description

-

-

STStartSigningCallback interface

The STStartSigningCallback interface is a callback interface with a method that controls the start of signature capture.

Java
interface STStartSigningCallback {
   void startSigning(boolean shouldStartSigning);
}

startSigning method

The method controls whether signature capture should be started.

Java
void startSigning(boolean shouldStartSigning);

Parameter

Description

boolean shouldStartSigning

true

The signature capture should be initiated.

false

The signature capture should not be initiated.

Return value

Description

-

-

Usage:

Java
void willStartSigning(String signatureFieldName, STStartSigningCallback startSigningCallback) {
   startSigningCallback.startSigning(true);
}

signingProcessStarted method

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

Java
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<STFormFieldInfoDTO>

Form fields that are to be set to ‘read only’ before signing, as a list of STFormFieldInfoDTO objects or null, if the form fields are not to be changed. Form fields that are already set to ‘read only’ will not be changed. If the user aborts the signature capture process, the form fields that have been passed will not be changed.

Usage:

Java
List<STFormFieldInfoDTO> signingProcessStarted(String signatureFieldName) {
  List<STTextFieldInfoDTO> allTextFieldsToDisable = signoSigner.getFormFields(EnumSet.of(TEXT));
  return allTextFieldsToDisable;
}

signingProcessConfirmed method

This method is called whenever the signature capture for a signature field has successfully ended and there is a signed document.

Java
void signingProcessConfirmed(String signatureFieldName);

Parameter

Description

String signatureFieldName

Name of the signature field for which the signature has been captured.

Return value

Description

-

-

Usage:

Java
void signingProcessConfirmed(String signatureFieldName) {
   // event handling
}

signingProcessCancelled method

This method is called if the signature capture process has been aborted by the user (with the ‘Cancel’ button).

Java
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:

Java
void signingProcessCancelled(String signatureFieldName) {
  // event handling
}

signingProcessFailed method

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

Java
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:

Java
void signingProcessFailed(String signatureFieldName, String errorMessage, String errorCode) {
  // event handling
}

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.

-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

The key container does not contain a certificate.

-136

The digital signature is too large and cannot be inserted into the document.

-137

An error occurred while creating the signature image.

-139

The document cannot be signed because the flag ‘NeedAppearances’ is set to true.

-145

The document could not be signed because of a problem with the xref table.

-146

The document could not be signed because of a time stamp problem.

-147

Unable to find the signature certificate in the key container.

-150

An unknown error occurred during the signature capture process.

signatureInfoPressed method

This method is called if the ‘Signature fields’ button in the toolbar has been tapped.

Java
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:

Java
boolean signatureInfoPressed {
  return true;
}

documentSaved method

This method is called if the ‘Save’ button in the toolbar has been tapped. Usually, in this event, the STSignoViewer.getDocumentAsFile() method should be called.

Java
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.

Usage:

Java
boolean documentSaved() {
  // event handling
  return true;
}

backButtonPressed method

This method is called if the ‘Back’ button in the toolbar has been tapped. Normally, the STSignoViewer.unloadDocument() method should be called. For further information, see also the STSignoViewer.unloadDocument() method.

Java
void backButtonPressed();

Parameter

Description

-

-

Return value

Description

-

-

Usage:

Java
void backButtonPressed() {
  // event handling
}

viewerRectConfirmed method

This method is called if the ‘Confirm’ button of a rectangle generated by calling STSignoViewer.createViewerRect() has been tapped. Usually, in this event, STSignoViewer.createNewSignatureField() or STSignoViewer.addImages() should be called.

Java
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 begins 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.

Usage:

Java
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() has been tapped.

Java
void viewerRectCancelled(int viewerRectId); 

Parameter

Description

int viewerRectId

Unique ID of the generated rectangle.

Return value

Description

-

-

Usage:

Java
void viewerRectCancelled(int viewerRectId) {
  // error handling
}