Some test text!

Search
Hamburger Icon

Android / Guides / Show/hide layers

Selectively browse PDF OCG layers in Android

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.

layer-browser

Show the OCG layer browser

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");
    }
}

Get the answers you need: Chat with us