DynaPDF Manual - Page 83

Previous Page 82   Index   Next Page 84

Layers (Optional Content)
Page 83 of 818
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
associated contents should become visibile or invisible. OCMDs can also be used with BeginLayer()
to create more complex visibility expressions.
Images and templates can be explicitely connected with an OCG or OCMD too. This can be useful in
situations where too many nested BeginLayer() calls would be required to create the same visibility
expression or if these object types belong to a specific layer. For example, if a document contains a
layer "Images" then it is easier and much more efficient to connect all images directly with that layer
in comparison to BeginLayer() / EndLayer() calls.
Viewer applications display layers in a tree structure like bookmarks. Which layers should appear in
the tree can be configured with AddLayerToDisplTree() as well as with CreateOCG(). It is not
required to add any layer to the layer tree. The visibility state of a layer that is not included in the
tree cannot be changed interactively in a viewer application. This can be useful in various situations,
e.g. to hide helper layers or simply to avoid changes by the user.
The visibility of layers can be changed dynamically with SetOCGState actions, Javascript, and with
application events. SetOCGState actions can be used if a user should be able to change the visibility
of a layer. Javascripts are useful if the visibility depends on calculations or other more complex
criteria.
The last way to change the visibility state dynamically is the usage of application events. PDF defines
events for exporting, printing, and viewing the document. The visibility of certain layers can be
changed in each of these events. See AddOCGToAppEvent() for further information.
 

Previous topic: Layers (Optional Content)

Next topic: PDF Transparency, Alpha Blending


Start Chat