DynaPDF Manual - Page 82
Previous Page 81 Index Next Page 83
Layers (Optional Content)
Page 82 of 821
Layers (Optional Content)
Layers in PDF are defined with so called Optional Content Groups (OCGs). When we talk about a
layer then we mean a piece of content that belongs to an OCG.
Layers provides the ability to dynamically hide or unhide graphical contents. The available API
functions to create and manipulate the visibility state of layers with DynaPDF are:
// Builds the layer tree for the GUI
// Adds an object to a layer
// Adds a layer to an application event
// Deletes a layer from an application event
• DeleteOCGFromDisplayTree() // Deletes a layer from the display tree
// Deletes an OCUINode from the display tree
// Opens a layer to add contents to it
// Closes the last open layer
// Changes an OCG or Layer name
// Optional Content Group (OCG)
// Optional Content Membership Dictionary (OCMD)
// Changes the visibility of a layer
// Returns the properties of a layer
// Returns a Content Usage dictionary (CUD)
// Returns the properties of an OCUINode
// Returns a user name of a CUD
// Returns the number of OCGs or layer
// Creates, changes, or deletes a CUD
// Changes the visibility state of a layer
// Locks a layer in the GUI
// Unlocks a layer
The creation of a layer begins always with the creation of an OCG. If we talk about a "layer" then we
mean in fact an OCG. An OCG specifies the layer name, the initial visibility state, and whether the
layer should be displayed in the user interface.
Note that the visibility of a layer in the user interface has nothing to do with the visibility of the
contents that belongs to it. Invisible layers can be used to avoid interaction with the user interface.
which change the visibility states depending on certain criteria, e.g. when printing the document, or
if the user should not be able to change the visibility.
Normal page contents, such as text, images, and vector graphics can be connected with a layer with
BeginLayer() / EndLayer(). Anything that is drawn between these function calls becomes part of the
layer. BeginLayer() calls can be nested to express dependencies to more than one layer. The visibility
of an inner layer depends then also on the visibility of the outer layer(s).
Annotations and Form Fields are not automatically added to a layer when created between
BeginLayer() / EndLayer() calls. These objects must be added to a layer with AddObjectToLayer()
since interactive objects are not part of the page contents.
Previous topic: Image Resolution
Next topic: PDF Transparency, Alpha Blending