DynaPDF Manual - Page 83
Previous Page 82 Index Next Page 84
Layers (Optional Content)
Page 83 of 839
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:
• AddLayerToDisplTree()
// Builds the layer tree for the GUI
• AddObjectToLayer()
// Adds an object to a layer
• AddOCGToAppEvent()
// Adds a layer to an application event
• DeleteOCGFromAppEvent()
// Deletes a layer from an application event
• DeleteOCGFromDisplayTree() // Deletes a layer from the display tree
• DeleteOCUINode()
// Deletes an OCUINode from the display tree
• BeginLayer()
// Opens a layer to add contents to it
• EndLayer()
// Closes the last open layer
• ChangeOCGName()
// Changes an OCG or Layer name
• CreateOCG()
// Optional Content Group (OCG)
• CreateOCMD()
// Optional Content Membership Dictionary (OCMD)
• CreateSetOCGStateAction()
// Changes the visibility of a layer
• GetOCG()
// Returns the properties of a layer
• GetOCGContUsage()
// Returns a Content Usage dictionary (CUD)
• GetOCUINode()
// Returns the properties of an OCUINode
• GetOCGUsageUserName()
// Returns a user name of a CUD
• GetOCGCount()
// Returns the number of OCGs or layer
• SetOCGContUsage()
// Creates, changes, or deletes a CUD
• SetOCGState()
// Changes the visibility state of a layer
• LockLayer()
// Locks a layer in the GUI
• UnLockLayer()
// 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.
This can be useful if the document contains SetOCGState or JavaScript actions, or application events
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