---
title: "Interact with DocumentView in Android Jetpack Compose | Nutrient"
canonical_url: "https://www.nutrient.io/guides/android/jetpack-compose/interactions/"
md_url: "https://www.nutrient.io/guides/android/jetpack-compose/interactions.md"
last_updated: "2026-06-08T09:14:14.289Z"
description: "Nutrient provides two ways to interact with DocumentView in your Android Jetpack Compose application:."
---

# Interacting with DocumentView

Nutrient provides two ways to interact with [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/index.html#DocumentView(android.net.Uri,androidx.compose.ui.Modifier)) in your Android Jetpack Compose application:

1. [`DocumentManager`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-manager/index.html)

2. [`DocumentConnection`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-connection/index.html)

## Document manager

[`DocumentManager`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-manager/index.html) provides multiple lifecycle and annotation callbacks.
To access `DocumentManager`, developers can make use of the `getDefaultDocumentManager()` method provided by default by the SDK.

`getDefaultDocumentManager()` provides `documentListener`, `annotationListener`, and `uiListener`. The following code snippet shows how to access them:

```kotlin

val documentState = rememberDocumentState(uri, configuration)

DocumentView(
    documentState = documentState,
    documentManager = getDefaultDocumentManager(
        documentListener = DefaultListeners.documentListeners(onDocumentLoaded = {...
        }),
        annotationListener = DefaultListeners.annotationListeners(onAnnotationSelected = { annotation, _ ->...
        }),
        uiListener = DefaultListeners.uiListeners(onImmersiveModeEnabled = { enabled ->...
        })
    )
)

```

The code below shows some of the document and annotation callbacks that are supported with [`DocumentManager`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-manager/index.html). We regularly expand on these, so it’s best to refer to the API documentation for the most up-to-date features:

```kotlin

@Immutable
class DocumentListener(
    val onDocumentLoaded: ((PdfDocument) -> Unit)? = null,
    val onDocumentLoadFailed: ((Throwable) -> Unit)? = null,
    val onDocumentSave: ((PdfDocument, DocumentSaveOptions) -> Boolean)? = null,
    val onDocumentSaved: ((PdfDocument) -> Unit)? = null,
    val onDocumentSaveFailed: ((PdfDocument, Throwable) -> Unit)? = null,
    val onDocumentSaveCancelled: ((PdfDocument?) -> Unit)? = null,
    val onPageClick: ((PdfDocument, Int, MotionEvent?, PointF?, Annotation?) -> Boolean)? = null,
    val onDocumentClick: (() -> Boolean)? = null,
    val onPageChanged: ((PdfDocument, Int) -> Unit)? = null,
    val onDocumentZoomed: ((PdfDocument, Int, Float) -> Unit)? = null,
    val onPageUpdated: ((PdfDocument, Int) -> Unit)? = null
)

@Immutable
class AnnotationListener(
    val onPrepareAnnotationSelection: ((AnnotationSelectionController, Annotation, Boolean) -> Boolean)? = null,
    val onAnnotationSelected: ((Annotation, Boolean) -> Unit)? = null,
    val onAnnotationDeselected: ((Annotation, Boolean) -> Unit)? = null
)

@Immutable
class UiListener(
    val onImmersiveModeEnabled: ((Boolean) -> Unit)? = null,
    val onDocumentScroll: ((ScrollState) -> Unit)? = null
)

```

## Document connection

[`DocumentConnection`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-connection/index.html) provides various actions that can be provided by [`DocumentView`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.views/index.html#DocumentView(android.net.Uri,androidx.compose.ui.Modifier)). It can be accessed via [`documentState`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-state/index.html), like so:

```kotlin

val documentState = rememberDocumentState(uri, pdfActivityConfiguration)
Column {
    DocumentView(documentState = documentState)
    Button(onClick = { documentState.documentConnection.setPageIndex(2) }) {
       Text("Go to page number 2")
    }
}

```

Currently [`DocumentConnection`](https://www.nutrient.io/api/android/nutrient/com.pspdfkit.jetpack.compose.interactors/-document-connection/index.html) provides two actions: `setPageIndex()` and `addAnnotationToPage()`.
---

## Related pages

- [Jetpack Compose PDF library](/guides/android/jetpack-compose.md)
- [Jetpack Compose PDF viewer](/guides/android/jetpack-compose/viewer.md)

