DynaPDF.CreateExtGState
-----------------------

Creates an extended graphics state object from the structure GS.

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

MBS( "DynaPDF.CreateExtGState"; PDF; JSON ) 

**MBS**( **"DynaPDF.CreateExtGState";** /\* Creates an extended graphics state object from the structure GS. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$JSON**) /\* The JSON describing the entries you like to initiaize. \*/ 

### Parameters

| Parameter | Description | Example |
|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |
| JSON | The JSON describing the entries you like to initiaize. |  |

### Result

Returns OK or error.

### Description

Creates an extended graphics state object from the structure GS.  
An extended graphics state can be used to adjust certain properties which are not part of the normal graphics state. Such properties can only be modified with a special PDF object called the Extended Graphics State.  
The most important properties of an extended graphics state are the transparency settings (PDF 1.4) and the overprint control (PDF 1.2 or 1.3, see below).  
The function creates an internal graphics state object and returns the handle of it. The extended graphics state can now be applied with [DynaPDF.SetExtGState](DynaPDFSetExtGState.md).  
Note that there is only way to restore the values of an extended graphics state, you must set a second extended graphics state that restores the values changed before. See DynaPDF.SaveGraphicsState and DynaPDF.RestoreGraphicsState.  
  
The following values are allowed in the JSON:  
  
| Key | value | PDF Version | default |
|---|---|---|---|
| AlphaIsShape | 0 or 1 | PDF 1.4 | unknown, does nothing |
| AutoStrokeAdjust | 0 or 1 | PDF 1.4 | 0 |
| BlendMode | Number of BlendMode | PDF 1.4 | Normal |
| FlatnessTol | 0.0..1.0 | all | none |
| FillAlpha | 0.0..1.0 | PDF 1.4 | 1.0 |
| OverPrintFill | 0 or 1 | PDF 1.2 if used alone, PDF 1.3 otherwise | 0 |
| OverPrintStroke | 0 or 1 | PDF 1.3 | 0 |
| OverPrintMode | 0 or 1 | PDF 1.3 | 0 |
| RenderingIntent | see RenderingIntents | PDF 1.1 | RelativeColorimetric |
| SmoothnessTol | 0.0..1.0 | PDF 1.3 | none |
| StrokeAlpha | 0.0..1.0 | PDF 1.4 | 1.0 |
| TextKnockout | 0 or 1 | PDF 1.4 | 1 |
| SoftMaskNone | true or false | all | false |

  
A value that should not be modified must not be changed.  
  
If an image should be inserted with transparency it is usually best to disable image transparency which based on color key masking (see [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)). Images use the fill alpha constant as alpha channel. Blend modes can be applied too. However, the result of blend modes depends strongly on the used color space. If the image is not defined in an ICC based color space then the result depends on the color management settings.  
Whenever transparency related settings are changed (FillAlpha, StrokeAlpha, or BlendMode) it is strongly recommended to attach an ICC profile of the output color space for which the file was created with [DynaPDF.AddOutputIntent](DynaPDFAddOutputIntent.md).  
If no output intent was specified, Adobe's Acrobat or Reader simulate a default CMYK color space as output color space if transparency is used on a page, also if the page uses RGB colors only! This differs from normal RGB files which use no transparency and causes often unwanted color changes.  
Note that this rule applies also to images which contain an alpha channel!  
If the PDF file uses RGB colors only, then attach an sRGB profile to the file. Such a profile is very small but it makes a huge difference whether the profile is present or not.  
  
If the function succeeds the return value is the extended graphics state handle, a value greater or equal zero. If the function fails the return value is an error.  
  
Rendering intents:  
  
| AbsoluteColorimetric | 0 |
|---|--:|
| Perceptual | 1, |
| RelativeColorimetric | 2 |
| Saturation | 3 |

  
Blend modes:  
  
| NotSet | 0 |
|---|--:|
| Normal | 1 |
| Color | 2 |
| ColorBurn | 3 |
| ColorDodge | 4 |
| Darken | 5 |
| Difference | 6 |
| Exclusion | 7 |
| HardLight | 8 |
| Hue | 9 |
| Lighten | 10 |
| Luminosity | 11 |
| Multiply | 12 |
| Overlay | 13 |
| Saturation | 14 |
| Screen | 15 |
| SoftLight | 16 |

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

### Examples

Set transparency:

 Set Variable \[ $json ; Value: JSONSetElement ( JSONSetElement ( "{}" ; "FillAlpha" ; .5 ; JSONNumber ) ; "StrokeAlpha" ; .5 ; JSONNumber ) \]  
Set Variable \[ $gs ; Value: MBS ("DynaPDF.CreateExtGState"; $pdf ; $json ) \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetExtGState](DynaPDFSetExtGState.md)"; $pdf ; $gs ) \]  
Enable overprint fill:

 Set Variable \[ $json ; Value: JSONSetElement ( JSONSetElement ( "{}" ; "OverPrintFill" ; 1; JSONNumber ) ; "OverPrintMode" ; 1 ; JSONNumber ) \]  
Set Variable \[ $gs ; Value: MBS ("DynaPDF.CreateExtGState"; $pdf ; $json ) \]  
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetExtGState](DynaPDFSetExtGState.md)"; $pdf ; $gs ) \]  
### See also

- [DynaPDF.AddOutputIntent](DynaPDFAddOutputIntent.md)
- [DynaPDF.CreateDeviceNColorSpace](DynaPDFCreateDeviceNColorSpace.md)
- [DynaPDF.Initialize](DynaPDFInitialize.md)
- [DynaPDF.New](DynaPDFNew.md)
- [DynaPDF.Save](DynaPDFSave.md)
- [DynaPDF.SetAlpha](DynaPDFSetAlpha.md)
- [DynaPDF.SetExtGState](DynaPDFSetExtGState.md)
- [DynaPDF.SetUseTransparency](DynaPDFSetUseTransparency.md)

### Release notes

- **Version 14.4**
    - Added [DynaPDF.CreateExtGState](https://www.mbsplugins.eu/DynaPDFCreateExtGState.shtml) and [DynaPDF.SetExtGState](https://www.mbsplugins.eu/DynaPDFSetExtGState.shtml) functions.

### Blog Entries

- [New in MBS FileMaker Plugin 14.4](https://www.mbsplugins.de/archive/2024-09-24/New_in_MBS_FileMaker_Plugin_14/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 14.4 für Claris FileMaker](https://www.mbsplugins.de/archive/2024-09-17/Neues_MBS_Plugin_144_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 14.4 for Claris FileMaker](https://www.mbsplugins.de/archive/2024-09-17/MBS_Plugin_144_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 14.4pr6](https://www.mbsplugins.de/archive/2024-09-11/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

Created 4th September 2024 , last changed 4th September 2024

  
[DynaPDF.CreateDeviceNColorSpace](DynaPDFCreateDeviceNColorSpace.md) - [DynaPDF.CreateGeospatialMeasure](DynaPDFCreateGeospatialMeasure.md)

[HTML Version](DynaPDFCreateExtGState.shtml)