How can I show a "tree" of PDF layers?


My document has some OCG layers. I’ve seen some documents where OCG layers are displayed as a hierarchical tree. How can I do that?


To get started using OCGs in PDFNet, you may want to take a look at the following code sample:

The sample shows how to make the visibility of some layers dependent on other layers, which you would need to implement proper “tree” semantics (so that, for example, disabling a parent disables its children).

You can then display hierarchies of OCGs using PDF.OCG.Config.SetOrder():

The argument to SetOrder() can be an array which itself contains arrays, enabling you to represent a tree of OCGs,