THotPDF.SetLoadedOCGVisibility Method
Controls the default visibility state of a specified optional content group (OCG, i.e., layer) in the loaded PDF
Declaration
procedure SetLoadedOCGVisibility(Index: Integer; AVisible: boolean);
Unit
HPDFDoc
Parameters
| Name | Purpose |
|---|---|
Index | Zero-based index of the OCG |
AVisible | Set to True to switch the layer ON in the default configuration, False to switch it OFF |
Return value
This member returns no value
Usage notes
- This method flips the OCG's default on/off state, which shapes how the document first appears in layer-aware viewers
- OCG visibility is only an advisory value; viewers can allow users to manually override it via the layers panel, and print outputs usually ignore visibility settings
- The document must be saved after modification; calling this method on a PDF without OCGs may cause an index out of bounds exception, so check the number of layers before calling