DynaPDF.BeginLayer
------------------

The function opens a layer in the current open page or template.

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

MBS( "DynaPDF.BeginLayer"; PDF; OCG ) 

**MBS**( **"DynaPDF.BeginLayer";** /\* The function opens a layer in the current open page or template. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$OCG**) /\* OCG or OCMD handle. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| OCG | OCG or OCMD handle. | $OCG |

### Result

Returns layer reference number or error.

### Description

The function opens a layer in the current open page or template.   
The layer must be closed with [DynaPDF.EndLayer](DynaPDFEndLayer.md) when finish. The parameter OCG must be valid handle of an Optional Content Group (OCG) or Optional Content Membership Dictionary (OCMD) (see [DynaPDF.CreateOCG](DynaPDFCreateOCG.md) and DynaPDF.CreateOCMD for further information). The OCG or OCMD controls the visibility of the contents that is included in the layer.   
DynaPDF.BeginLayer/[DynaPDF.EndLayer](DynaPDFEndLayer.md) calls connect normal page contents, such as text, images, and vector graphics with a layer but no interactive objects like annotations or form fields. Annotations and Form Fields can be added to a layer with DynaPDF.AddObjectToLayer.   
It is not required to draw the entire contents of a layer in one pass. The page contents can be drawn as usual and delimited into DynaPDF.BeginLayer/[DynaPDF.EndLayer](DynaPDFEndLayer.md) calls as necessary. Only contents that is delimited into DynaPDF.BeginLayer/[DynaPDF.EndLayer](DynaPDFEndLayer.md) calls becomes part of a layer.   
Layers can be nested by calling DynaPDF.BeginLayer more than one time with different OCGs or OCMDs. The visibility of an inner layer depends then also on the visibility of the out ones (see example below). If an outer layer is invisible then all inner layers are invisible too, regardless of the visibility settings of the inner layers. A layer is not part of the graphics state. Neither DynaPDF.BeginLayer nor [DynaPDF.EndLayer](DynaPDFEndLayer.md) change any parameter of the graphics state. DynaPDF.BeginLayer must not be called within an open path.   
See also [BeginLayer](https://www.monkeybreadsoftware.com/DynaPDF-Manual/BeginLayer.shtml) function in DynaPDF manual.

### See also

- [DynaPDF.BeginPattern](DynaPDFBeginPattern.md)
- [DynaPDF.CreateOCG](DynaPDFCreateOCG.md)
- [DynaPDF.EndLayer](DynaPDFEndLayer.md)
- [DynaPDF.LockLayer](DynaPDFLockLayer.md)
- [DynaPDF.New](DynaPDFNew.md)

### Release notes

- **Version 11.5**
    - Fixed problem in [DynaPDF.BeginLayer](https://www.mbsplugins.eu/DynaPDFBeginLayer.shtml).

### Blog Entries

- [MBS FileMaker Plugin, version 11.5pr2](https://www.mbsplugins.de/archive/2021-10-11/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 6th February 2015 , last changed 6th February 2015

  
[DynaPDF.BeginContinueText](DynaPDFBeginContinueText.md) - [DynaPDF.BeginPattern](DynaPDFBeginPattern.md)

[HTML Version](DynaPDFBeginLayer.shtml)