Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 73

Previous Page 72   Index   Next Page 74

Layers (Optional Content)
Page 73 of 750
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()
// Connects an object with a layer
AddOCGToAppEvent()
// Adds a layer to an application event
DeleteOCGFromAppEvent()
// Deletes a layer from an application event
BeginLayer()
// Opens a layer to add contents to it
EndLayer()
// Closes the last open layer
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)
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.
Annotations and Form Fields can be connected with exactly one OCG or OCMD (Optional Content
Membership Dictionary). OCMDs are used if the visibility should depend on more than one layer.
An OCMD accepts an array of OCG handles and a visibility expression that specifies when the
 

Previous topic: Image Resolution

Next topic: Alpha Blending