Skip to main content

Quick start

This guide walks you through a complete signature: your app shows a PDF, the user reads it and signs it with their handwritten signature, and the SDK returns the signed document with the encrypted biometric data embedded.

#StepCall
1Add the viewMobbSignView
2Configure the licenseconfigureLicense()
3Set the encryption keysetEncryptionKey()
4Listen to the eventssetOn…Listener()
5Load the documentloadPDFDocument()
Before you begin

The SDK is installed and you have a license key and the public encryption key of your project.

1. Add the view​

MobbSignView displays the document, its toolbars and the signature capture. Add it to your layout:

activity_sign.xml
<com.mobbeel.mobbsign.view.MobbSignView
android:id="@+id/mobbsignview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="vertical|horizontal" />

You can also create it in code. To customise it, pass a Bundle with the customisation properties:

Bundle customizationBundle = new Bundle();
// Customisation properties, see Customisation
mobbSignView = new MobbSignView(this, customizationBundle);
setContentView(mobbSignView);

2. Configure the license​

Configure the license before any other call. The listener receives the result of the validation and the expiry date of the license:

mobbSignView.configureLicense("YOUR_LICENSE_KEY", new LicenseStatusListener() {
@Override
public void onLicenseStatusChecked(Date licenseValidTo, MobbSignLicenseResult licenseResult) {
// VALID, NOT_VALID, EXPIRED…
}
});

Without a valid license the document is displayed, but it cannot be signed.

3. Set the encryption key​

Load the public key of your project and pass it to the SDK. It encrypts the biometric data of every signature. This example reads a PEM key from the assets folder with Bouncy Castle:

Security.addProvider(new BouncyCastleProvider());
PEMParser reader = new PEMParser(new InputStreamReader(getAssets().open("mobbsign.key")));
PublicKey publicKey = null;
Object obj;
while (publicKey == null && (obj = reader.readObject()) != null) {
if (obj instanceof SubjectPublicKeyInfo) {
publicKey = new JcaPEMKeyConverter().getPublicKey((SubjectPublicKeyInfo) obj);
} else if (obj instanceof PublicKey) {
publicKey = (PublicKey) obj;
}
}
mobbSignView.setEncryptionKey(publicKey);
Use your production key

The test key included in the distribution is only for development. Before you release your app, replace it with the public key generated for your project. See The life of a signature.

4. Listen to the events​

Register the listeners you need. These three cover a basic integration:

mobbSignView.setOnDocumentSignedListener((document, encryptedSignatureData, signatureBitmap, signaturePage, signatureCoord) -> {
// A signature has been added to the document
});

mobbSignView.setOnProcessEndListener(document -> {
// The user has finished: `document` contains the signed PDF
});

mobbSignView.setOnErrorOccurredListener((errorCode, errorDetails) -> {
// See Error codes
});

See all the events in Configuration.

5. Load the document​

Load the PDF to sign. The second parameter is the title shown in the viewer:

mobbSignView.loadPDFDocument(getAssets().open("contract.pdf"), "Service contract");

The viewer opens the document. The user can turn the pages and zoom in, tap Sign to draw their signature on the screen and confirm it. When they finish, onProcessEnd delivers the signed PDF.

6. Keep the signed document​

onProcessEnd returns the bytes of the signed PDF. From that moment your app is responsible for the document: send it to your backend, store it and keep it for the period required. The signed PDF is self-contained: it carries the encrypted biometric data and can be verified with any PDF reader.

Next step​

Learn the license states, all the events and the ways to load a document in Configuration.