DynaPDF.GetOCG
--------------

Returns properties for layer.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [9.1](newinversion91.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.GetOCG"; PDF; Handle; Selector ) 

**MBS**( **"DynaPDF.GetOCG";** /\* Returns properties for layer. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Handle**; /\* The OCG handle.e.g. $OCG \*/   
**$Selector**) /\* Which value to return.e.g. "Name" \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| Handle | The OCG handle. | $OCG |
| Selector | Which value to return. | "Name" |

### Result

Returns value or error.

### Description

Returns properties for layer.  
returns the properties of the Content Usage dictionary that is associated with an OCG or layer. If the OCG is not included in an application event, then the contents in this dictionary serves as pure information.   
If the OCG is included in one or more application events, then these settings control also the visibility state of the OCG. The function DynaPDF.GetOCG returns the events and categories which control the layer visibility.   
If UserNamesCount is greater zero, the dictionary contains also user names. The user names can be accessed with [DynaPDF.GetOCGUsageUserName](DynaPDFGetOCGUsageUserName.md).   
  
Properties:  
| Handle | Handle or array index |
|---|---|
| Intent | Bitmask, see TOCGIntent. For Intent and visibility state |
| Name | Layer name |
| HaveContUsage | If 1, the layer contains a Content Usage dictionary. See [DynaPDF.GetOCGContUsage](DynaPDFGetOCGContUsage.md) |
| AppEvents | Bitmask, see TOCAppEvent. If non-zero, the layer is included in one or more app events which control the layer state. |
| Categories | Bitmask, see TOCGUsageCategory. The Usage Categories which control the layer state. |

See also [GetOCG](https://www.monkeybreadsoftware.com/DynaPDF-Manual/GetOCG.shtml) function in DynaPDF manual.

### Examples

Find layers in PDF:

 Set Variable \[ $pdf ; Value: MBS ("[DynaPDF.New](DynaPDFNew.md)") \]   
\#   
\# import file   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)"; $pdf ; Layers::Input PDF) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)"; $pdf ; 1) \]   
\#   
\# look for layers   
Set Variable \[ $count ; Value: MBS ( "[DynaPDF.GetOCGCount](DynaPDFGetOCGCount.md)" ; $pdf ) \]   
Set Variable \[ $index ; Value: 0 \]   
Loop  
 Exit Loop If \[ $index ≥ $count \]   
 #   
 Set Variable \[ $Name ; Value: MBS ( "DynaPDF.GetOCG" ; $pdf ; $index ; "Name" ) \]   
 Set Variable \[ $Intent ; Value: MBS ( "DynaPDF.GetOCG" ; $pdf ; $index ; "Intent" ) \]   
 Set Variable \[ $Visible ; Value: MBS ( "[Math.BitwiseAND](MathBitwiseAND.md)"; $intent ; 32 ) = 32 \]   
 #  
 New Record/Request  
 Set Field \[ Layers::Name ; $name \]   
 Set Field \[ Layers::Visible ; $visible \]   
 Commit Records/Requests \[ With dialog: Off \]   
 #   
 Set Variable \[ $index ; Value: $index + 1 \]   
End Loop  
\#   
Set Variable \[ $r ; Value: MBS ( "[DynaPDF.Release](DynaPDFRelease.md)"; $pdf ) \]  
### See also

- [DynaPDF.CreateOCG](DynaPDFCreateOCG.md)
- [DynaPDF.GetBBox](DynaPDFGetBBox.md)
- [DynaPDF.GetOCGContUsage](DynaPDFGetOCGContUsage.md)
- [DynaPDF.GetOCGUsageUserName](DynaPDFGetOCGUsageUserName.md)
- [DynaPDF.ImportPDFPage](DynaPDFImportPDFPage.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.OpenPDFFromContainer](DynaPDFOpenPDFFromContainer.md)
- [DynaPDF.Release](DynaPDFRelease.md)
- [DynaPDF.SetOCGState](DynaPDFSetOCGState.md)
- [Math.BitwiseAND](MathBitwiseAND.md)

### Release notes

- **Version 9.1**
    - Added [DynaPDF.GetOCG](http://www.mbsplugins.eu/DynaPDFGetOCG.shtml), [DynaPDF.GetOCGContUsage](http://www.mbsplugins.eu/DynaPDFGetOCGContUsage.shtml), [DynaPDF.GetOCGCount](http://www.mbsplugins.eu/DynaPDFGetOCGCount.shtml), [DynaPDF.GetOCGUsageUserName](http://www.mbsplugins.eu/DynaPDFGetOCGUsageUserName.shtml) and [DynaPDF.SetOCGState](http://www.mbsplugins.eu/DynaPDFSetOCGState.shtml) functions for PDF layers.

### Blog Entries

- [MBS FileMaker Plugin, version 9.1pr4](https://www.mbsplugins.de/archive/2019-02-25/MBS_FileMaker_Plugin_version_9/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 18th February 2019 , last changed 18th February 2019

  
[DynaPDF.GetNeedAppearance](DynaPDFGetNeedAppearance.md) - [DynaPDF.GetOCGContUsage](DynaPDFGetOCGContUsage.md)

[HTML Version](DynaPDFGetOCG.shtml)