> 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/guides/android/bookmark/outline.md).

# Outline tree (Android)

Learn how to work with an outline tree in Xamarin.Android using a UI component or API guide. Display outlines & bookmarks, set bookmarks, and navigate PDF documents programmatically. The Apryse Xamari

There are two options to working with an outline tree. First is using a UI component that provides tools to set a bookmark or display the outline. Second is an API guide to programmatically read outline items.

{% tabs %}
{% tab title="UI component" %}

## Display outlines & bookmarks in Android

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

The [`OutlineDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.OutlineDialogFragment.html) displays a document outline (containing PDF `Bookmarks` that can be used to navigate the PDF document by selecting a bookmark item.

![](https://653871032-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FgjsBtuYmcKhWOdM9VCg4%2Fuploads%2Fgit-blob-70d682efd843654067aaa1eda10edfa72af76763%2Fcf7d5120d7c199b14fec80aefd804b573704dac8-810x1710.png?alt=media)

## Show outline dialog

To show an outline dialog fragment in your activity, create a new instance of [`OutlineDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.OutlineDialogFragment.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 outlineDialog = new DialogFragmentTab(
        Java.Lang.Class.FromType(typeof(OutlineDialogFragment)), BookmarksTabLayout.TagTabOutline, null, "Outline", "Bookmarks Dialog", null);
    tabs.Add(outlineDialog);
    bookmarksDialog.SetDialogFragmentTabs(tabs);
    bookmarksDialog.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
    bookmarksDialog.Show(fragmentManager, "bookmarks_dialog");
    return bookmarksDialog;
}
```

{% endcode %}

You can also set the current bookmark using `setCurrentBookmark(Bookmark)`.

## Listener

You can set a listener to be notified when an item in an [`OutlineDialogFragment`](https://sdk.apryse.com/api/xamarinandroid/tools/api/pdftron.PDF.Controls.OutlineDialogFragment.html) is clicked by calling `setOutlineDialogListener(OutlineDialogListener)`.
{% endtab %}

{% tab title="API guide" %}

## API to programmatically read, edit & create outlines / bookmarks

To navigate an outline tree and print its result.

{% code lineNumbers="true" %}

```csharp
void PrintIdent(Bookmark item)
{
  int ident = item.GetIdent() - 1;
  for (int i=0; i < ident; ++i) {
    Console.Write("  ");
  }
}
void PrintOutlineTree(Bookmark item)
{
  for (; item.IsValid(); item=item.GetNext()) {
    PrintIdent(item);
    Console.Write("{0:s}{1:s} ACTION -> ", (item.IsOpen() ? "- " : "+ "), item.GetTitle());
    if (item.HasChildren()) {
      PrintOutlineTree(item.GetFirstChild());
    }
  }
}
PDFDoc doc = new PDFDoc(filename);
Bookmark root = doc.GetFirstBookmark();
PrintOutlineTree(root);
```

{% endcode %}

[Read, add, edit PDF outlines and bookmarks](/xamarin/get-started/samples.md#bookmarks) Full code sample which illustrates how to read and edit existing outline items and create new bookmarks using the high-level API.

## About outline tree

A PDF document may display a document outline on the screen, allowing the user to navigate interactively from one part of the document to another. The outline consists of a tree-structured hierarchy of Bookmarks (sometimes called outline items), which serve as a "visual table of contents" to display the document's structure to the user.

Each Bookmark has a title that appears on screen, and an Action that specifies what happens when a user clicks on the Bookmark. The typical Action for a user-created Bookmark is to move to another location in the current document — although any Action can be specified.
{% 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.apryse.com/xamarin/guides/android/bookmark/outline.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
