Jetpack Compose Toolbar

Since PSPDFKit for Android 2024.2, our SDK provides a Toolbar that’s made entirely with Jetpack Compose. This toolbar is fully customizable and can be used with DocumentView. It’s an alternative version of our default toolbar, specifically designed to be used more flexibly with Jetpack Compose.

Just like top app bars, our MainToolbar has modifier, title, navigationIcon, and actions as parameters, as well as the documentState:

@Composable
fun MainToolbar(
    modifier: Modifier = Modifier,
    documentState: DocumentState,
    title: @Composable ((String) -> Unit)? = null,
    navigationIcon: @Composable (tintColor: Color) -> Unit = {},
    actions: @Composable RowScope.(tintColor: Color) -> Unit = {}
)

Usage

MainToolbar can be used in the following way:

MainToolbar(documentState = documentState)

Make sure to disable the default toolbar by adding disableDefaultToolbar to the existing PdfActivityConfiguration as follows:

val pdfActivityConfiguration = PdfActivityConfiguration
        .Builder(context)
        .disableDefaultToolbar()
        .build()

val documentState = rememberDocumentState(pdf.toUri(), pdfActivityConfiguration)

Exploring Further

We have a dedicated GitHub public repository demonstrating everything related to DocumentView and the MainToolbar.