# Sign PDF with Kotlin

This guide will assist you in integrating DocuSeal document e-signing capabilities into your Android app. With DocuSeal, you can create document templates from your PDF files, send them to the signers, and receive signed copies. Templates can be created either using our [web UI](https://docuseal.com/sign_up) or through the [API](https://www.docuseal.com/docs/api.md). For instance, you can design a document template with various field types using [HTML and CSS](https://www.docuseal.com/blog/creating-fillable-pdf-document-forms-with-html.md) or [PDF upload](https://www.docuseal.com/guides/use-embedded-text-field-tags-in-the-pdf-to-create-a-fillable-form.md). More information on this can be found in our [guides](https://www.docuseal.com/guides.md).

## How to sign PDFs with Kotlin

- Create a [DocuSeal account](https://docuseal.com/sign_up).
- Create a document template using [web UI](https://docuseal.com/sign_up) or [API](https://www.docuseal.com/docs/api.md).
- Embed a signing form in your app.

### Embedded Signing Form

To embed a signing form in your Android app, you need to use a WebView. The WebView will load the script, and the user can sign the document using the DocuSeal Signing Form. Therefore, you first need to add dependencies to your project's **build.gradle** file.

To do this, open the **build.gradle** file in the **app** folder of your project and add the following code to the **dependencies** block:

 
```
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'androidx.webkit:webkit:1.4.0'
```

Now you need to allow your app to use the internet. To do this, open the **AndroidManifest.xml** file in the **app/src/main** folder and add the following code:

 
```
<uses-permission android:name="android.permission.INTERNET"/>
```

If necessary, create a layout file **activity_main.xml** in your project and add a **WebView** to it:

 
```
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <WebView
    android:id="@+id/webView"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />
</RelativeLayout>
```

This is all you need to create the layout. Below is the code that you can use as an example to add a signing form to your app:

 
```
package com.example.docusealapp

import android.os.Bundle
import androidx.activity.ComponentActivity
import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient

class MainActivity : ComponentActivity() {
    private lateinit var webView: WebView

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        webView = findViewById(R.id.webView)
        setupWebView()
        loadHtmlContent()
    }

    private fun setupWebView() {
        webView.settings.javaScriptEnabled = true
        webView.settings.domStorageEnabled = true
        webView.webViewClient = object : WebViewClient() {
            override fun shouldOverrideUrlLoading(view: WebView?, request: WebResourceRequest?): Boolean {
                return false
            }
        }
    }

    private fun loadHtmlContent() {
        val html = """
            <html>
                <head>
                    <meta name="viewport" content="width=device-width, initial-scale=1.0">
                    <script src="https://cdn.docuseal.com/js/form.js"></script>
                </head>
                <body>
                    <docuseal-form
                        id="docusealForm"
                        data-src="https://docuseal.com/d/LEVGR9rhZYf86M"
                        data-email="signer@example.com">
                    </docuseal-form>
                </body>
            </html>
        """
        webView.loadDataWithBaseURL(null, html, "text/html", "UTF-8", null)
    }
}
```

After adding this code to your app, you will see such a signing form in your app. However, you can customize its appearance and behavior using many parameters. You can read more about this in our [documentation](https://www.docuseal.com/docs/embedded/form.md) or check out a complete example of an Android app in our [repository](https://github.com/docusealco/docuseal-android-example).

### Conclusions

In this guide, we have only covered the most basic example of using DocuSeal in an Android app. DocuSeal has many other capabilities that you can use to enhance your app. For example, you can embed not only the Signing form on your app but also the [Form builder](https://www.docuseal.com/docs/embedded/builder.md). You can also use the API to fully automate the [process of generating custom documents using HTML](https://www.docuseal.com/blog/creating-fillable-pdf-document-forms-with-html.md) and then sending them for signing without using the DocuSeal web UI.

### Related Links

- [Embed PDF signing in Android App](https://www.docuseal.com/guides/embed-document-signing-into-android-app.md)
- [API Documentation](https://www.docuseal.com/docs/api.md)
- [Webhooks Documentation](https://www.docuseal.com/docs/api/form-webhook.md)
- [Developer Guides](https://www.docuseal.com/guides.md)
- [Creating Fillable PDF Document Forms with HTML](https://www.docuseal.com/blog/creating-fillable-pdf-document-forms-with-html.md)