| Category | Optional content |
|---|---|
| Exported names | pdfCreateOCGA, pdfCreateOCGW |
| Availability | Partial — DisplayInUI/Intent accepted, not applied — see Remarks |
Purpose — Create a new optional-content group (a "layer").
Description — Registers a new OCG with Name and its initial Visible state, which becomes both the current display state and the default state restored by pdfLoadLayerConfig(0). The engine assigns an internal PDF-name alias (OC1, OC2, …) used to reference the layer from content streams via /OC /OCn BDC — this alias, not Name, is what pdfBeginLayer writes into the page content.
Declarations
int32_t __stdcall pdfCreateOCGA(PPDF IPDF, const char* Name, BOOL32 DisplayInUI, BOOL32 Visible, TOCGIntent Intent);
int32_t __stdcall pdfCreateOCGW(PPDF IPDF, const wchar_t* Name, BOOL32 DisplayInUI, BOOL32 Visible, TOCGIntent Intent);
function pdfCreateOCGA(const IPDF: PPDF; const Name: PAnsiChar; DisplayInUI, Visible: LongBool; Intent: TOCGIntent): Integer; stdcall; external 'LumasPdf.dll';
function pdfCreateOCGW(const IPDF: PPDF; const Name: PWideChar; DisplayInUI, Visible: LongBool; Intent: TOCGIntent): Integer; stdcall; external 'LumasPdf.dll';
TOCGIntent (from Lumas.Pdf.Types, bit values):
TOCGIntent = Cardinal;
const oiDesign = 2; oiView = 4; oiAll = 8; oiEmpty = 16; oiVisible = 32;
Parameters
| Parameter | Type | Description |
|---|---|---|
IPDF | PPDF | Instance handle. |
Name | string | Layer name shown in a viewer's layer panel. |
DisplayInUI | BOOL32 | Accepted for ABI compatibility; not applied — see Remarks. |
Visible | BOOL32 | Initial ON/OFF state — this one is real; drives both the current and default visibility. |
Intent | TOCGIntent | Accepted for ABI compatibility; not applied — see Remarks. |
Return value — 1-based OCG handle (> 0). This function cannot otherwise fail — it only appends to an in-memory table.
Remarks — compatibility parameters. DisplayInUI and Intent are accepted to match the reference ABI shape but are not stored or serialized; every OCG created here is discoverable in the display tree (subject to pdfDeleteOCGFromDisplayTree) and carries no per-OCG /Intent entry — only pdfCreateOCLayerConfig's Intent parameter reaches the file (as the alternate-configuration's /Intent). If your workflow depends on per-layer UI-visibility or intent flags, they are not representable through this call in the current engine.
See also — pdfBeginLayer, pdfChangeOCGName
C# (P/Invoke)
public static extern int pdfCreateOCGA(IntPtr IPDF, [MarshalAs(UnmanagedType.LPStr)] string Name, [MarshalAs(UnmanagedType.Bool)] bool DisplayInUI, [MarshalAs(UnmanagedType.Bool)] bool Visible, uint Intent);
public static extern int pdfCreateOCGW(IntPtr IPDF, [MarshalAs(UnmanagedType.LPWStr)] string Name, [MarshalAs(UnmanagedType.Bool)] bool DisplayInUI, [MarshalAs(UnmanagedType.Bool)] bool Visible, uint Intent);
Object Creation
pdfCreateOCGA
pdfCreateOCGW
The …A form takes UTF-8, …W
takes UTF-16; a bare name aliases the ANSI form.
Worked examples — complete programs in ten languages.