OptionalContentGroup

OptionalContentGroup

Overview

OptionalContentGroup is a class in Aspose.PDF FOSS for .NET.

Represents an Optional Content Group (layer) in a PDF document.

This class provides 9 methods for working with OptionalContentGroup objects in .NET programs. Available methods include: AddContent, Delete, Flatten, Lock, OptionalContentGroup, Save, Unlock. All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package. Properties: Contents, DefaultState, Id, Intent, IsLocked, IsVisible, and 2 more.

Properties

NameTypeAccessDescription
NamestringReadThe layer name.
Idstring?ReadThe OCG identifier used in page Resources/Properties (e.g.
IsVisibleboolRead/WriteWhether this layer is currently visible.
IsLockedboolRead/WriteWhether this layer is locked (cannot be toggled by users).
LockedboolRead/WriteAlias for IsLocked.
DefaultStateDefaultStateRead/WriteThe default visibility state of this layer.
Intentstring?ReadThe intent of this layer (e.g., “View”, “Design”).
ContentsIReadOnlyList<byte[]>ReadGets the content operators (as raw bytes) belonging to this layer from the page content stream (BDC/EMC markers) or from XForm streams that reference this layer’s OCG.

Methods

SignatureDescription
OptionalContentGroup(id: string, name: string)Create a new layer with the given id and name.
Lock()Lock this layer so it cannot be toggled by users.
Unlock()Unlock this layer.
Flatten(cleanupContentStream: bool)Flatten this layer — remove the BDC/EMC markers but keep the content.
Delete()Delete this layer and all its content from the page.
Save()Save the content of this layer to a new single-page PDF document.
Save(stream: Stream)Save the content of this layer to a stream as a new single-page PDF.
Save(outputPath: string)Save the content of this layer to a file as a new single-page PDF.
AddContent(op: Operators.Operator)Add a content operator to this layer (for newly created layers).

See Also