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:
// Builds the layer tree for the GUI
// Connects an object with a layer
// Adds a layer to an application event
// Deletes a layer from an application event
// Opens a layer to add contents to it
// Closes the last open layer
// Optional Content Group (OCG)
// Optional Content Membership Dictionary (OCMD)
CreateSetOCGStateAction() // Changes the visibility of a layer
// Returns the properties of a layer
// Returns a Content Usage dictionary (CUD)
// 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.
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