This section explains how to work with PDF Layers, as follows:
- Layer Objects and Visibility
- Layers Diagram
- Visibility Policy
- Working with Containers, Dictionaries and Layers using ImageGear PDF sample
For more information, see Using ImageGear PDF Component and HIG_PDF_DICTIONARY and HIG_PDF_LAYER.
Layer Objects and Visibility
The following objects are related to PDF Layers and responsible for the visibility.
Layers
Each layer has a name and a visibility state for the containers connected to the layer through a Dictionary. The visibility state can have one of two values - ON or OFF.
Dictionaries
Each dictionary contains the array of layers and a Boolean function, which takes all the layers' states as input and applies the visibility policy function to the layers' state values producing the Boolean result whether or not to display all the objects from the dictionary's container. The output can have one of two values - ON or OFF.
Containers
Each container is an arbitrary set of PDF elements or other containers. Each container is associated with a dictionary. The container and all its elements (including the other containers) are displayed when its dictionary's visibility policy Boolean function results with ON.
The following diagram shows the relationship between containers and the other PDF document objects:
Layers Diagram
The following diagram shows interconnection between PDF objects and layers:
Visibility Policy
Dictionary Boolean functions define the visibility policy. It can be one of the following:
- AllOn - equivalent to "AND" function for all input parameters,
- AnyOn - equivalent to "OR" function for all input parameters,
- AnyOff - equivalent to "NOT-OR" function for all input parameters,
- AllOff - equivalent to "NOT-AND" function for all input parameters,
In other words:
AllOn | All the containers from the dictionary will be displayed when all the input layers' states are `ON' |
AnyOn | All the containers from the dictionary will be displayed when at least one of the input layers state is `ON' |
AnyOff | All the containers from the dictionary will be displayed when at least one of the input layers state is `OFF' |
AllOff | All the containers from the dictionary will be displayed when all the input layers' states are `OFF' |
Working with Containers, Dictionaries and Layers using ImageGear PDF sample
Before creating a container you need to create one or more layers using the View -> Layers menu. Make sure to create some simple elements like text, paths or images as well.
In order to create container right click on the PDF page and select Create -> Container. You will be prompted to select all the layers you want to associate with the containers dictionary, which will affect the container's visibility. You also need to select the visibility policy and check all the elements you want to include into the new container. When container is created a new dictionary is automatically created as well.
To show or hide the container's elements use View -> Layers menu to change the layer's state to ON or OFF.
In order to rearrange the container's elements you can right click to delete the existing container, which will free its elements and create the new one.