---
Product: Aspose.PDF
Platform: net
Page Type: reference
Canonical URL: https://reference.aspose.org/pdf/net/OptionalContentBuilder
---

# OptionalContentBuilder

## Overview

`OptionalContentBuilder` is a class in Aspose.PDF FOSS for .NET.

Creates optional content groups (layers) in a PDF document.

This class provides 5 methods for working with OptionalContentBuilder objects in .NET programs.
Available methods include: `AddLayer`, `BeginLayer`, `Build`, `EndLayer`, `OptionalContentBuilder`.
All public members are accessible to any .NET application after installing the Aspose.PDF FOSS for .NET package.

## Methods

| Signature | Description |
|-----------|-------------|
| `OptionalContentBuilder(document: Document)` | Calls OptionalContentBuilder on this OptionalContentBuilder instance. |
| `AddLayer(name: string, visible: bool)` | Add a new layer (Optional Content Group). |
| `Build()` | Finalize and write the OCProperties to the document catalog. |
| `BeginLayer(layer: LayerEntry)` | Get the BDC/EMC content stream operators to wrap content in a layer. |
| `EndLayer()` | End marker for a layer content sequence. |

## See Also

- [Aspose.PDF for .NET — Enterprise API Reference](https://reference.aspose.com/pdf/net/)