Some test text!

Loading...
Guides

Selectively browse PDF OCG layers in Xamarin

This tutorial only applies to Xamarin.Android. See the Xamarin.iOS equivalent here .

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) {
    var pdfLayerDialogFragment = PdfLayerDialogFragment.NewInstance();
    pdfLayerDialogFragment.SetPdfViewCtrl(pdfViewCtrl);
    pdfLayerDialogFragment.SetStyle((int)DialogFragmentStyle.NoTitle, Resource.Style.PDFTronAppTheme);
    if (fragmentManager != null) {
        pdfLayerDialogFragment.Show(fragmentManager, "pdf_layer_dialog");
    }
}

Get the answers you need: Support

UPCOMING WEBINAR: Live tech update and run-through. October 21 @ 11am PDT