> For the complete documentation index, see [llms.txt](https://docs.apryse.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.apryse.com/android/bookmarks/user-bookmarks-a.md).

# User-defined bookmarks in Android

Manage user-defined bookmarks efficiently with Apryse's specific feature. Learn how to navigate PDFs seamlessly and export bookmarks in JSON format. Click to explore more! The Apryse Android SDK strea

{% hint style="warning" %}
**User-defined bookmarks are an Apryse specific feature that may not show in other PDF viewer applications. If you want to manage PDF bookmarks so that they can be processed in other standard PDF viewers, see the document outline guide .**
{% endhint %}

The [`UserBookmarkDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/UserBookmarkDialogFragment.html) displays a list of user-defined bookmarks that can be used to navigate the document.

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-222550db548264bb533adae814bf9d6384f373d4%2F5e833372cc4a34933785e770242e543aa74a3e74-1080x2160.png?alt=media)

## Show user bookmark dialog

To show a user bookmark dialog fragment in your activity, create a new instance of [`UserBookmarkDialogFragment`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/controls/UserBookmarkDialogFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/android/javadoc/reference/com/pdftron/pdf/PDFViewCtrl.html):

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
BookmarksDialogFragment showBookmarksDialog(FragmentManager fragmentManager, PDFViewCtrl pdfViewCtrl) {
    DialogFragmentTab userBookmarksDialog = new DialogFragmentTab(
        UserBookmarkDialogFragment.class,
        BookmarksTabLayout.TAG_TAB_BOOKMARK,
        null,
        "User Bookmarks",
        "Bookmarks Dialog",
        null);
    ArrayList<DialogFragmentTab> dialogFragmentTabs = new ArrayList<>();
    dialogFragmentTabs.add(userBookmarksDialog);

    BookmarksDialogFragment bookmarksDialog = BookmarksDialogFragment.newInstance();
    bookmarksDialog.setPdfViewCtrl(pdfViewCtrl)
        .setDialogFragmentTabs(dialogFragmentTabs);
    bookmarksDialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme);   
    bookmarksDialog.show(fragmentManager, "bookmarks_dialog");
    return bookmarksDialog;
}
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
fun showBookmarksDialog(fragmentManager: FragmentManager, pdfViewCtrl: PDFViewCtrl): BookmarksDialogFragment {
    val userBookmarksDialog = DialogFragmentTab(
        UserBookmarkDialogFragment::class.java!!,
        BookmarksTabLayout.TAG_TAB_BOOKMARK, null,
        "User Bookmarks",
        "Bookmarks Dialog", null)
    val dialogFragmentTabs = ArrayList<DialogFragmentTab>()
    dialogFragmentTabs.add(userBookmarksDialog)
    
    val bookmarksDialog = BookmarksDialogFragment.newInstance()
    bookmarksDialog.setPdfViewCtrl(pdfViewCtrl)
                   .setDialogFragmentTabs(dialogFragmentTabs)
    bookmarksDialog.setStyle(DialogFragment.STYLE_NO_TITLE, R.style.PDFTronAppTheme)
    bookmarksDialog.show(fragmentManager, "bookmarks_dialog")
    return bookmarksDialog
}
```

{% endcode %}
{% endtab %}
{% endtabs %}

## Listener

You can set a listener to be notified when a user bookmark is clicked by calling `setUserBookmarkListener(UserBookmarkDialogListener)`.

## Read-only

If the document has write access, users can add new user bookmarks using floating action button. To specify whether the document is read-only call `setReadOnly(boolean)`.

## Import and export

It is possible to import and export user bookmarks in JSON format. Typical use case is to save and load the user bookmarks JSON from a server.

The user bookmark JSON is a dictionary with page indices as keys and the bookmark title as the values. For example: `{"0":"Bookmark 1","2":"Bookmark 2"}`. Behaviour is undefined otherwise. Note that the page indices will be 0-indexed similar to XFDF.

{% tabs %}
{% tab title="Java" %}
{% code lineNumbers="true" %}

```java
// import
BookmarkManager.importPdfBookmarks(PDFViewCtrl, String);
// export
BookmarkManager.exportPdfBookmarks(PDFDoc);
```

{% endcode %}
{% endtab %}

{% tab title="Kotlin" %}
{% code lineNumbers="true" %}

```kotlin
// import
BookmarkManager.importPdfBookmarks(PDFViewCtrl, String)
// export
BookmarkManager.exportPdfBookmarks(PDFDoc)
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.apryse.com/android/bookmarks/user-bookmarks-a.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
