> 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/xamarin/bookmarks/user-bookmarks.md).

# User bookmarks list

Learn how to create and manage user-defined bookmarks for Xamarin.Android with Apryse SDK. Import, export, and navigate through PDF documents effortlessly. Click to explore more! The Apryse Xamarin SD

Apryse SDK allows you to create a maintain a list of user defined bookmarks.

{% tabs %}
{% tab title="Android" %}

## User-defined bookmarks for Xamarin.Android

{% hint style="info" %}
**This tutorial only applies to Xamarin.Android. See Xamarin.iOS equivalent here .**
{% endhint %}

{% 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/xamarinandroid/tools/api/pdftron.PDF.Controls.UserBookmarkDialogFragment.html) displays a list of user-defined bookmarks that can be used to navigate the document.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%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/xamarinandroid/tools/api/pdftron.PDF.Controls.UserBookmarkDialogFragment.html) by calling `newInstance()` and setting the [`PDFViewCtrl`](https://sdk.apryse.com/api/xamarinandroid/pdfnet/api/pdftron.PDF.PDFViewCtrl.html):

{% code lineNumbers="true" %}

```csharp
fun showBookmarksDialog(fragmentManager: FragmentManager, pdfViewCtrl: PDFViewCtrl): BookmarksDialogFragment {
    var bookmarksDialog = pdftron.PDF.Dialog.BookmarksDialogFragment.NewInstance();
    bookmarksDialog.SetPdfViewCtrl(pdfViewCtrl);
    List<DialogFragmentTab> tabs = new List<DialogFragmentTab>();
    var userBookmarksDialog = new DialogFragmentTab(
        Java.Lang.Class.FromType(typeof(UserBookmarkDialogFragment)), BookmarksTabLayout.TagTabBookmark, null, "User Bookmarks", "Bookmarks Dialog", null);
    tabs.Add(userBookmarksDialog);
    bookmarksDialog.SetDialogFragmentTabs(tabs);
    bookmarksDialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
    bookmarksDialog.Show(fragmentManager, "bookmarks_dialog");
    return bookmarksDialog;
}
```

{% endcode %}

## 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.

{% code lineNumbers="true" %}

```csharp
// import
BookmarkManager.ImportPdfBookmarks(PDFViewCtrl, String)
// export
BookmarkManager.ExportPdfBookmarks(PDFDoc)
```

{% endcode %}
{% endtab %}

{% tab title="iOS" %}

## User-defined bookmarks for Xamarin.iOS

{% hint style="info" %}
**This tutorial only applies to Xamarin.iOS. See Xamarin.Android equivalent here .**
{% endhint %}

The [`PTBookmarkViewController`](https://sdk.apryse.com/api/xamarinios/tools/api/pdftron.PDF.Controls.PTBookmarkViewController.html) class shows a list of user-defined bookmarks that can be used to navigate through the document. The user-defined bookmarks are Apryse specific features that may not be shown in other PDF viewer apps. If you want to manage PDF bookmarks so that they can be processed in other standard PDF viewers, see the [outline view controller guide](/xamarin/guides/ios/bookmark/outline.md#ui-component).

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-0c6671767140fba510adb152c66b82b412cd37b6%2F57576f04ec374441f9486f31f92fdcb519bf9119-1242x2208.png?alt=media)

*The user bookmarks control is part of the Tools library, so make sure you have* [*added the Tools library to your project*](/xamarin/ui-customization/setup.md)*.*

## Show a bookmark view controller

To create a new bookmark view controller instance and display it from another view controller, supply a `PTPDFViewCtrl` instance to the `PTBookmarkViewController` designated initializer:

{% code lineNumbers="true" %}

```csharp
var bookmarkViewController = new pdftron.PDF.Controls.PTBookmarkViewController (mPdfViewCtrl);
bookmarkViewController.BookmarkViewControllerBookmarkSelected += (sender, e) => {
    // perform custom action
    this.DismissViewController (true, null);
};
bookmarkViewController.BookmarkViewControllerDidCancel += (object sender, EventArgs e) => {
    this.DismissViewController (true, null);
};

var navigationController = new UINavigationController (bookmarkViewController);
if (UserInterfaceIdiomIsPad)
{
    navigationController.ModalPresentationStyle = UIModalPresentationStyle.Popover;
    navigationController.PopoverPresentationController.BarButtonItem = bookmarksButton;
}

this.PresentViewController (navigationController, true, null);
```

{% endcode %}

{% hint style="info" %}
**The bookmark view controller must be pushed onto a navigation controller's stack before being shown.**
{% endhint %}

{% hint style="info" %}
**Presenting on iPads:**

The bookmark view controller is designed to be presented in a popover on iPads. To do so, you must provide the `PTBookmarkViewController`'s [`PopoverPresentationController`](https://docs.microsoft.com/en-us/dotnet/api/uikit.uipopoverpresentationcontroller) with either:

* a [`SourceRect`](https://docs.microsoft.com/en-us/dotnet/api/uikit.uipopoverpresentationcontroller.sourcerect#UIKit_UIPopoverPresentationController_SourceRect) AND
* a [`SourceView`](https://docs.microsoft.com/en-us/dotnet/api/uikit.uipopoverpresentationcontroller.sourceview#UIKit_UIPopoverPresentationController_SourceView)

OR

* a [`BarButtonItem`](https://docs.microsoft.com/en-us/dotnet/api/uikit.uipopoverpresentationcontroller.barbuttonitem#UIKit_UIPopoverPresentationController_BarButtonItem)

as in the example above.
{% endhint %}

You can set a delegate to be notified by the bookmark view controller when bookmarks are selected with the `PTBookmarkViewControllerDelegate` protocol. (See the CompleteReader example for usage of a `PTBookmarkViewController`.
{% 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/xamarin/bookmarks/user-bookmarks.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.
