Class PdfLayer
An optional content group is a dictionary representing a collection of graphics that can be made visible or invisible dynamically by users of viewer applications.
public class PdfLayer : PdfObjectWrapper<PdfDictionary>, IPdfOCG
- Inheritance
-
PdfLayer
- Implements
- Inherited Members
Remarks
An optional content group is a dictionary representing a collection of graphics
that can be made visible or invisible dynamically by users of viewer applications.
In iText they are referenced as layers.
To be able to be wrapped with this
PdfObjectWrapper<T>
the
PdfObject
must be indirect.
Constructors
PdfLayer(string, PdfDocument)
Creates a new layer by its name and document.
public PdfLayer(string name, PdfDocument document)
Parameters
name
stringthe layer name
document
PdfDocumentthe PdfDocument which the layer belongs to
PdfLayer(PdfDictionary)
Creates a new layer by existing dictionary, which must be an indirect object.
public PdfLayer(PdfDictionary layerDictionary)
Parameters
layerDictionary
PdfDictionarythe layer dictionary, must have an indirect reference.
Fields
children
protected IList<PdfLayer> children
Field Value
locked
protected bool locked
Field Value
on
protected bool on
Field Value
onPanel
protected bool onPanel
Field Value
parent
protected PdfLayer parent
Field Value
title
Used for titling group of objects but not actually grouping them.
protected string title
Field Value
Methods
AddChild(PdfLayer)
Adds a child layer.
public virtual void AddChild(PdfLayer childLayer)
Parameters
childLayer
PdfLayerthe child layer
Remarks
Adds a child layer. Nested layers can only have one parent.
AddOCGRadioGroup(PdfDocument, IList<PdfLayer>)
Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm.
public static void AddOCGRadioGroup(PdfDocument document, IList<PdfLayer> group)
Parameters
document
PdfDocumentthe
PdfDocument
group
IList<PdfLayer>the radio group
Remarks
Use this method to set a collection of optional content groups whose states are intended to follow a "radio button" paradigm. That is, the state of at most one optional content group in the array should be ON at a time: if one group is turned ON, all others must be turned OFF.
CreateTitle(string, PdfDocument)
Creates a title layer.
public static PdfLayer CreateTitle(string title, PdfDocument document)
Parameters
title
stringthe title text
document
PdfDocumentthe
PdfDocument
Returns
- PdfLayer
the title layer
Remarks
Creates a title layer. A title layer is not really a layer but a collection of layers under the same title heading.
CreateTitleSilent(string, PdfDocument)
Creates a title layer without registering it in PdfOCProperties.
protected static PdfLayer CreateTitleSilent(string title, PdfDocument document)
Parameters
title
stringthe title of the layer
document
PdfDocumentthe document this title layer belongs to
Returns
- PdfLayer
the created layer
GetChildren()
Gets the list of the current child layers of the layer.
public virtual IList<PdfLayer> GetChildren()
Returns
Remarks
Gets the list of the current child layers of the layer. BE CAREFUL! Do not try to add a child layer using the resultant child list, use #addChild method instead.
GetDocument()
Gets the PdfDocument that owns that layer.
protected virtual PdfDocument GetDocument()
Returns
- PdfDocument
the PdfDocument that owns that layer
GetIndirectReference()
Gets the indirect reference to the current layer object.
public virtual PdfIndirectReference GetIndirectReference()
Returns
- PdfIndirectReference
the indirect reference to the object representing the layer
GetIntents()
Gets a collection of current intents specified for this layer.
public virtual ICollection<PdfName> GetIntents()
Returns
- ICollection<PdfName>
the collection of intents.
Remarks
Gets a collection of current intents specified for this layer. The default value is View , so it will be the only element of the resultant collection if no intents are currently specified.
GetParent()
Gets the parent of this layer, be it a title layer, or a usual one.
public virtual PdfLayer GetParent()
Returns
- PdfLayer
the parent of the layer, or null if it has no parent
GetTitle()
Gets the title of the layer if it is a title layer, or null if it is a usual layer.
public virtual string GetTitle()
Returns
- string
the title of the layer if it is a title layer, or null if it is a usual layer
GetUsage()
Gets the /Usage dictionary, creating a new one if necessary.
protected virtual PdfDictionary GetUsage()
Returns
- PdfDictionary
the /Usage dictionary
IsLocked()
Gets whether the layer is currently locked or not.
public virtual bool IsLocked()
Returns
- bool
true if the layer is currently locked, false otherwise.
Remarks
Gets whether the layer is currently locked or not. If the layer is locked, it will not be possible to change its state (on/off) in a viewer.
IsOn()
Gets the initial visibility of the layer when the document is opened.
public virtual bool IsOn()
Returns
- bool
the initial visibility of the layer
IsOnPanel()
Gets the layer visibility in Acrobat's layer panel
public virtual bool IsOnPanel()
Returns
- bool
the layer visibility in Acrobat's layer panel
IsWrappedObjectMustBeIndirect()
protected override bool IsWrappedObjectMustBeIndirect()
Returns
SetCreatorInfo(string, string)
Used by the creating application to store application-specific data associated with this optional content group.
public virtual void SetCreatorInfo(string creator, string subtype)
Parameters
creator
stringa text string specifying the application that created the group
subtype
stringa string defining the type of content controlled by the group. Suggested values include but are not limited to Artwork, for graphic-design or publishing applications, and Technical, for technical designs such as building plans or schematics
SetExport(bool)
Specifies the recommended state for content in this group when the document (or part of it) is saved by a viewer application to a format that does not support optional content (for example, an earlier version of PDF or a raster image format).
public virtual void SetExport(bool export)
Parameters
export
boolthe export state
SetIntents(IList<PdfName>)
Sets the intents of the layer.
public virtual void SetIntents(IList<PdfName> intents)
Parameters
SetLanguage(string, bool)
Specifies the language of the content controlled by this optional content group
public virtual void SetLanguage(string lang, bool preferred)
Parameters
lang
stringa language string which specifies a language and possibly a locale (for example, es-MX represents Mexican Spanish)
preferred
boolused by viewer applications when there is a partial match but no exact match between the system language and the language strings in all usage dictionaries
SetLocked(bool)
Use this method to lock an optional content group.
public virtual void SetLocked(bool locked)
Parameters
locked
boolsets whether the layer is currently locked or not
Remarks
Use this method to lock an optional content group. The state of a locked group cannot be changed through the user interface of a viewer application. Producers can use this entry to prevent the visibility of content that depends on these groups from being changed by users.
SetName(string)
Sets the name of the layer to be displayed in the Layers panel.
public virtual void SetName(string name)
Parameters
name
stringthe name of the layer.
SetOn(bool)
Sets the initial visibility of the layer when the document is opened.
public virtual void SetOn(bool on)
Parameters
on
boolthe initial visibility of the layer
SetOnPanel(bool)
Sets the visibility of the layer in Acrobat's layer panel.
public virtual void SetOnPanel(bool onPanel)
Parameters
onPanel
boolthe visibility of the layer in Acrobat's layer panel
Remarks
Sets the visibility of the layer in Acrobat's layer panel. If false
the layer cannot be directly manipulated by the user. Note that any children layers will
also be absent from the panel.
SetPageElement(string)
Indicates that the group contains a pagination artifact.
public virtual void SetPageElement(string pe)
Parameters
pe
stringone of the following names: "HF" (Header Footer), "FG" (Foreground), "BG" (Background), or "L" (Logo).
SetPrint(string, bool)
Specifies that the content in this group is intended for use in printing
public virtual void SetPrint(string subtype, bool printState)
Parameters
subtype
stringa name specifying the kind of content controlled by the group; for example, Trapping, PrintersMarks and Watermark
printState
boolindicates that the group should be set to that state when the document is printed from a viewer application
SetUser(string, params string[])
Specifies one or more users for whom this optional content group is primarily intended.
public virtual void SetUser(string type, params string[] names)
Parameters
type
stringa name that can be Ind (individual), Ttl (title), or Org (organization).
names
string[]one or more text strings representing the name(s) of the individual, position or organization
SetView(bool)
Indicates that the group should be set to that state when the document is opened in a viewer application.
public virtual void SetView(bool view)
Parameters
view
boolthe view state
SetZoom(float, float)
Specifies a range of magnifications at which the content in this optional content group is best viewed.
public virtual void SetZoom(float min, float max)
Parameters
min
floatthe minimum recommended magnification factors at which the group should be ON. A negative value will set the default to 0
max
floatthe maximum recommended magnification factor at which the group should be ON. A negative value will set the largest possible magnification supported by the viewer application