> 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/layers-ocgs/ocg-layer-browser-a.md).

# Selectively browse PDF OCG layers in Android

Discover how to use a PDF OCG dictionary to manage graphic objects with the PdfLayerDialogFragment. Learn how to control visibility and rendering of layers in your PDF documents. Explore the OCG layer

A PDF OCG (Optional Content Groups) dictionary represents a collection of graphic objects that can be made visible or invisible. Any graphic content of the PDF can be made optional, including page contents, XObjects, and annotations.

The `PdfLayerDialogFragment` allows you to browse OCG layers associated with the document. You can selectively render layers based on their states. In a tree view of nested layers, if the parent layer is hidden, the child layers are automatically hidden as well. If the parent layer is visible, child layers can be made visible or hidden.

![](https://226546913-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F0QItsdFBmuuL9ezHimHy%2Fuploads%2Fgit-blob-c05c630dc07dd900692cc117020e05f47e597521%2Ffdfbb9483f163a86bf1d84032616482f8b83a3eb-366x728.gif?alt=media)

## Show the OCG layer browser

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

```java
public void show(PDFViewCtrl pdfViewCtrl, FragmentManager fragmentManager) {
    PdfLayerDialogFragment pdfLayerDialogFragment = PdfLayerDialogFragment.newInstance();
    pdfLayerDialogFragment.setPdfViewCtrl(pdfViewCtrl);
    pdfLayerDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE, ((ToolManager) pdfViewCtrl.getToolManager()).getTheme());
    if (fragmentManager != null) {
        pdfLayerDialogFragment.show(fragmentManager, "pdf_layer_dialog");
    }
}
```

{% endcode %}
{% endtab %}

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

```kotlin
fun show(pdfViewCtrl: PDFViewCtrl, fragmentManager: FragmentManager) {
    val pdfLayerDialogFragment = PdfLayerDialogFragment.newInstance()
    pdfLayerDialogFragment.setPdfViewCtrl(pdfViewCtrl)
    pdfLayerDialogFragment.setStyle(DialogFragment.STYLE_NO_TITLE, (pdfViewCtrl.toolManager as ToolManager).theme)
    if (fragmentManager != null) {
        pdfLayerDialogFragment.show(fragmentManager, "pdf_layer_dialog")
    }
}
```

{% 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/layers-ocgs/ocg-layer-browser-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.
