---
title: "eSign PDF with certificate on Android | Nutrient SDK"
canonical_url: "https://www.nutrient.io/guides/android/signatures/using-electronic-signatures-and-digital-signatures-together/"
md_url: "https://www.nutrient.io/guides/android/signatures/using-electronic-signatures-and-digital-signatures-together.md"
last_updated: "2026-05-20T19:49:34.727Z"
description: "ESign PDF with certificate on Android | guide for Nutrient Android SDK with detailed instructions and code examples."
---

# eSign PDFs with a certificate on Android

This guide shows how Electronic Signatures and Digital Signatures can be used together.

To combine using the Electronic Signatures signing UI with digitally signing a document using a certificate, your activity needs to implement two interfaces: an [`OnSignaturePickedListener`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.signatures.listeners/-on-signature-picked-listener/index.html), and a [`DocumentSigningListener`][]. The `OnSignaturePickedListener` will allow you to override [`onSignaturePicked`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.signatures.listeners/-on-signature-picked-listener/on-signature-picked.html), which can then be used to apply the created signature annotation to a digital signature. The `DocumentSigningListener` will enable you to access the signed document once it has been saved, in case you need to display it.

It could look something like this:

```kotlin

class MyActivity :
    PdfActivity(),
    OnSignaturePickedListener,
    DocumentSigningListener {

    private var signatureFormFieldName: String? = null

    override fun onSignaturePicked(signature: Signature) {
        val document = document?: return
        // Signature form name can be obtained from an `addOnFormElementClickedListener`.
        val signatureFormFieldName = this.signatureFormFieldName?: return

        val formField = document.formProvider.getFormFieldWithFullyQualifiedName(signatureFormFieldName)

        // The signature object provides convenient conversion to ink or stamp annotation.
        val signatureAnnotation: Annotation = when (signature.annotationType) {
            AnnotationType.INK -> signature.toInkAnnotation(
                document,
                formField.formElement.pageIndex,
                formField.formElement.boundingBox)
            AnnotationType.STAMP -> signature.toStampAnnotation(
                document,
                formField.formElement.pageIndex,
                formField.formElement.boundingBox)
            else -> throw IllegalStateException("Unhandled Signature type. Neither Ink, nor Stamp.")
        }

        // Add the annotation to the document. This step is required so we can render the signature
        // to pass the render to the `SignatureAppearance`.
        document.annotationProvider.addAnnotationToPage(signatureAnnotation)

        val w = kotlin.math.abs(signatureAnnotation.boundingBox.width().toInt())
        val h = kotlin.math.abs(signatureAnnotation.boundingBox.height().toInt())
        val signatureBitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888)
        signatureAnnotation.renderToBitmap(signatureBitmap)

        // Now that we've made the bitmap, we can remove the annotation from the document.
        document.annotationProvider.removeAnnotationFromPage(signatureAnnotation)

        // Now sign the document with a certificate asset in the next function.
        signDocumentWithSignatureBitmap(formField.formElement as SignatureFormElement, signatureBitmap)
    }

    private fun signDocumentWithSignatureBitmap(formElement: SignatureFormElement, signatureBitmap: Bitmap) {

        val path = FileUtils.getTempFilePath(applicationContext, "pdf")
        val temporaryFile = File(path?: "")

        val signatureAppearance = SignatureAppearance(
            signatureGraphic = SignatureGraphic.fromBitmap(getImageUri(signatureBitmap)))
        )

        val key = getPrivateKeyEntry(applicationContext)
        val signedDocumentUri = Uri.fromFile(temporaryFile)
        val signerOptions = SignerOptions.Builder(formElement.formField, signedDocumentUri).setSignatureMetadata(DigitalSignatureMetadata(signatureAppearance = signatureAppearance)).setPrivateKey(key).build()

        // Handles the signing process.
        SigningManager.signDocument(
              context = applicationContext,
              signerOptions = signerOptions,
              type = DigitalSignatureType.CADES,
              onFailure = { // Handle signing errors here. }
                   )
                {
                    // Replace the loaded document with the signed document.
                    setDocumentFromUri(signedDocumentUri, null)
                }
    }
}

```

You can see a working Catalog example of this code [here](https://github.com/PSPDFKit/pspdfkit-android-catalog/blob/9eac1be5767cdeb5a58d879d0749c2338d4f77fb/app/src/main/java/com/pspdfkit/catalog/examples/kotlin/CombineElectronicSignaturesWithDigitalSigningExample.kt).
---

## Related pages

- [How to add electronic signatures to PDFs on Android](/guides/android/signatures/adding-an-electronic-signature.md)
- [How to save and store electronic signatures on Android](/guides/android/signatures/signature-storage.md)

