10
Modifying the User Interface
Working with PDF Layers
Editing the Properties of PDF Layers
The
OCG
object provides properties that can be used to determine whether the object’s
default state should be on or off, whether its intent should be for viewing or design
purposes, whether it should be locked, the text string seen in the user interface, and the
current state. The properties are shown below in
Table 10.15:
T
ABLE
10.15
OCG Properties
Property
Description
Determines whether the
OCG
object is on or off by
default
The intent of the
OCG
object (View or Design)
Whether the on/off state can be toggled through the user
interface
The text string seen in the user interface for the
OCG
object
The current on/off state of the
OCG
object
initState
intent
locked
name
state
The
initState
property can be used to set the default state for an optional content
group. In the following example,
myLayer
is set to
on
by default:
myLayer.initState = true;
The
intent
property, which is an array of values, can be used to define the intent of a
particular optional content group. There are two possible values used in the array:
View
and
Design
. A
Design
layer is created for informational purposes only, and does not
affect the visibility of content. Its purpose is to represent a document designer’s structural
organization of artwork. The
View
layer is intended for interactive use by document
consumers. If
View
is used, the visibility of the layer is affected. In the following example,
the intent of all the
OCG
objects in the document is set to both values:
var ocgs = this.getOCGs();
for (var i=0; i<ocgs.length; i++)
ocgs[i].intent = ["View", "Design"];
The
locked
property is used to determine whether a given layer can be toggled through
the user interface. In the following example,
myLayer
is locked, meaning that it cannot be
toggled through the user interface:
myLayer.locked = true;
The
state
property represents the current on/off state for a given OCG. In the following
example, all the OCGs are turned on:
var ocgs = this.getOCGs();
for (var i=0; i<ocgs.length; i++)
ocgs[i].state = true;
188
Acrobat JavaScript Scripting Guide